我每次只得到这三个选项 在我的整个代码正常工作期间,我们将不胜感激。
let selections = pdfView.currentSelection?.selectionsByLine()
guard (selections?.first?.pages.first) != nil else { return }
selections?.forEach({ selection in
let newAnnotation = PDFAnnotation(bounds: selection.bounds(for: pdfView.currentPage!) ,forType: PDFAnnotationSubtype.highlight ,withProperties: nil)
// Add additional properties to the annotation
newAnnotation.color = #colorLiteral(red: 0.9254902005, green: 0.2352941185, blue: 0.1019607857, alpha: 1)
self.pdfView.currentPage?.displaysAnnotations = true
self.pdfView.currentPage?.addAnnotation(newAnnotation)
})
答案 0 :(得分:0)
我也在努力解决这个问题,但是找不到将它添加到iOS中的PDFView的任何选项。 最后,我偶然发现了通过共享UIMenuController类添加菜单项的通用方法。
let menuItem = UIMenuItem(title: "Highlight", action: #selector(HighLightHandler.highlightSelection(_:)))
UIMenuController.shared.menuItems = [menuItem]
并处理所有亮点:
@objc func highlightSelection(_ sender: UIMenuItem) {
//put your highlighting code here
}