将注释添加到PDFPage(并在屏幕上呈现)后,无法在PDFPage/ 上更新其外观PDFView.
重现问题:
创建PDFAnnotation并将其添加到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)
Run Code Online (Sandbox Code Playgroud)在PDFPage上显示后,尝试编辑其边界/颜色/背景颜色/字符串值等:
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)
Run Code Online (Sandbox Code Playgroud)什么都没发生.
我知道一个诀窍:
page.removeAnnotation(annotation)
page.addAnnotation(annotation)
Run Code Online (Sandbox Code Playgroud)
但这是一种解决方法,而不是真正的解决方案.