我已经设置了一个 PDFViewer 并想添加一个突出显示功能,以便当用户选择文本时,他们可以突出显示它。当您在笔记、iMessages 等中突出显示文本时,您可以选择全选、复制、粘贴等。您将如何编辑它以便同时拥有突出显示功能?此外,应用程序如何保存突出显示,以便当用户关闭并重新打开应用程序时,他们仍然能够查看突出显示的文本?这会涉及使用核心数据还是其他东西?谢谢!
问问题
1666 次
1 回答
4
let select = pdfView.currentSelection?.selectionsByLine()
//assuming for single-page pdf.
guard let page = select?.first?.pages.first else { return }
select?.forEach({ selection in
let highlight = PDFAnnotation(bounds: select.bounds(for: page), forType: .highlight, withProperties: nil)
highlight.endLineStyle = .square
highlight.color = UIColor.orange.withAlphaComponent(0.5)
page.addAnnotation(highlight)
})
于 2019-07-03T05:30:06.280 回答