gpt4 book ai didi

ios - 如何使用 PDFKit 突出显示 pdf 中选定的文本?

转载 作者:行者123 更新时间:2023-11-29 05:37:51 24 4
gpt4 key购买 nike

我已经设置了一个 PDFViewer,并希望添加突出显示功能,以便当用户选择文本时,他们可以突出显示它。当您突出显示笔记、iMessage 等中的文本时,您可以选择全部选择、复制、粘贴等。您将如何编辑它以便也可以拥有突出显示功能?此外,应用程序如何保存突出显示,以便当用户关闭并重新打开应用程序时,他们仍然能够查看突出显示的文本?这会涉及使用核心数据还是其他什么?谢谢!

this is a screenshot of the default functionalities that Apple provides but I would like to add an additional highlighting functionality

最佳答案

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)
})

关于ios - 如何使用 PDFKit 突出显示 pdf 中选定的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56860727/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com