'Swift PDFKit handle annotation widget change?
Is it possible to handle on change in swift pdf annotations? I would like to highlight the fields that need to be filled and then unhighlight when they have been filled.
pdfView.document = PDFDocument(url: url!)
for index in 0..<pdfView.document!.pageCount{
if let page = pdfView.document?.page(at: index){
let annotations = page.annotations
for annotation in annotations{
print("Annotation Name :: \(annotation.fieldName ?? "")")
annotation.backgroundColor = .opaqueSeparator
switch annotation.fieldName {
case "Customer":
annotation.widgetStringValue = "Customer"
annotation.backgroundColor = .tertiarySystemFill
case "Customer Email":
annotation.widgetStringValue = "Customer Email"
annotation.backgroundColor = .tertiarySystemFill
default:
annotation.widgetStringValue = ""
}
annotation.onChanged{ value in
annotation.backgroundColor = .opaqueSeparator
}
}
}
}
Annotations do not have a onChange or onChanged, what is the best way to go about this.
Thanks for any help!!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
