我正在添加注释,但无法删除添加的注释。例如:当我搜索“Tubes”这个词时,它会标记每个“t”字母。
示例图像:
我只想注释“管”字。
以及如何删除我添加的所有注释。我该如何解决这些问题?
这是代码:
var pdfView: PDFView!
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
return highlight(searchTerms: [searchText])
}
public func highlight(searchTerms: [String]?)
{
var highlight = PDFAnnotation()
searchTerms?.forEach { term in
let selections = pdfView?.document?.findString(term, withOptions: [.forcedOrdering])
selections?.forEach { selection in
selection.pages.forEach { page in
highlight = PDFAnnotation(bounds: selection.bounds(for: page), forType: .highlight, withProperties: nil)
highlight.endLineStyle = .square
highlight.color = UIColor.yellow.withAlphaComponent(0.5)
page.addAnnotation(highlight)
}
}
}
}
感谢所有帮助:)