小编Raf*_*acz的帖子

将PDFAnnotationSubtype等于.widget的PDFAnnotation在将其添加到PDFPage后不会刷新其外观

将注释添加到PDFPage(并在屏幕上呈现)后,无法在PDFPage/ 上更新其外观PDFView.

重现问题:

  1. 创建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)
  2. 在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)

但这是一种解决方法,而不是真正的解决方案.

pdfkit ios swift ios11

10
推荐指数
1
解决办法
979
查看次数

标签 统计

ios ×1

ios11 ×1

pdfkit ×1

swift ×1