The "Highlight" context menu item is part of the default UIEditMenuInteraction, which is now the preferred way to handle text selection and editing in PDFView. To remove the "Highlight" menu item, you can override the editMenuInteraction property of your PDFView and set its menuItems property to an empty array.
Here is an example of how to do this:
class MyViewController: UIViewController {
@IBOutlet weak var pdfView: PDFView!
override func viewDidLoad() {
super.viewDidLoad()
// Remove the "Highlight" menu item from the default UIEditMenuInteraction
pdfView.editMenuInteraction?.menuItems = []
}
}
This will remove the "Highlight" menu item from the context menu that appears when you long press to select text in a PDF.
You can also use the UIEditMenuInteraction to add custom menu items to the context menu. To do this, you can add items to the menuItems property of the UIEditMenuInteraction.
class MyViewController: UIViewController {
@IBOutlet weak var pdfView: PDFView!
override func viewDidLoad() {
super.viewDidLoad()
// Create a custom menu item
let myMenuItem = UIMenuItem(title: "My Item", action: #selector(myMenuItemTapped))
// Add the custom menu item to the default UIEditMenuInteraction
pdfView.editMenuInteraction?.menuItems.append(myMenuItem)
}
@objc func myMenuItemTapped() {
// Do something when the custom menu item is tapped
}
}
I hope this helps!