PDFAnnotation with a PDFAnnotationSubtype equal to .widget does not refresh its appearance after adding it to PDFPage

After adding the annotation to PDFPage (and displayed on the screen) there is no way to update its appearance on PDFPage / PDFView .

To reproduce the problem:

  • Create a PDFAnnotation and add it to PDFPage :

     let bounds = CGRect(x: 20.0, y: 20.0, width: 200.0, height: 200.0) let annotation = PDFAnnotation(bounds: b, forType: .widget, withProperties: nil) annotation.widgetFieldType = .text annotation.backgroundColor = .gray annotation.font = .systemFont(ofSize: 18) annotation.widgetStringValue = "Test!" page.addAnnotation(annotation) 
  • After it is presented in PDFPage, try editing its borders / color / background color / line value, etc.:

     annotation?.setValue("Help! SOS! Mayday!", forAnnotationKey: .widgetValue) annotation?.color = .green annotation?.bounds = CGRect(x: 0.0, y: 0.0, width: 100.0, height: 100.0) 

Nothing happens.

I know the trick:

  page.removeAnnotation(annotation) page.addAnnotation(annotation) 

but this is more a workaround than a real solution.

+7
ios swift pdfkit ios11
source share

No one has answered this question yet.

See similar questions:

one
Apple PDFKit: Free Draw with Ink Annotation

or similar:

657
How do you start a block after a delay, for example -performSelector: withObject: afterDelay :?
497
Codesign error: Provisioning profile cannot be found after deleting an expired profile
404
The status bar and navigation bar are displayed according to my viewing restrictions in iOS 7
314
Unacceptable Devices section appeared in Xcode 6.xx
211
How to use pull to update in Swift?
2
iOS PDFKit: make a PDF widget textAnnotation readonly
0
Swift PDFKit Annotation Widgets
0
Draw a PDFPage in a subclass of UIView in the draw (_ :) method (scale / transform so it doesn't work correctly)
0
Trigger In-App-Browser after listening to annotations using PDFKit - iOS 11

All Articles