I use pdfkit and I want to customize the menu contents of the selected text that appears. When I long-press and select the text, the system menu pops up with the highlight option, and nothing happens when I click on highlight. I want to customize the menu and replace the highlight copy and other options on the current system.
My code implementation:
class MyPDFVC: UIViewController, PDFViewDelegate {
let pdfView = PDFView()
override func viewDidLoad() {
super.viewDidLoad()
pdfView.frame = CGRect(x: 0, y: 0, width:
self.view.frame.width, height: self.view.frame.height)
pdfView.isUserInteractionEnabled = true
pdfView.delegate = self
self.view.addSubview(pdfView)
//加载的 PDF 文件
if let pdfURL = Bundle.main.url(forResource: "SPR-pdf", withExtension: "pdf"), let pdfDocument = PDFDocument(url: pdfURL) {
pdfView.document = pdfDocument
pdfView.goToFirstPage(nil)
}
}
}
The imageShot is: https://i.sstatic.net/FaMTn.png