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.
ios swift pdfkit ios11
Rafał Rębacz
source share