将注释添加到PDFPage(并在屏幕上呈现)后,无法在PDFPage
/ PDFView
上更新其外观。
重现问题:
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)
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)
什么都没发生。
我知道一个诀窍:
page.removeAnnotation(annotation)
page.addAnnotation(annotation)
但这是一种解决方法,而不是真正的解决方案。
你不能只使用'FreeText'类型的PDFAnnotation。更改边界时,将更新此注释类型的大小。我知道这种类型不是用户可编辑的,但也许你不需要这样。