1

在此处输入图像描述

每次我的整个代码都在工作时,我只得到这 3 个选项,我们将不胜感激。

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

1 回答 1

1

我也在努力解决这个问题,但找不到任何选项将其添加到 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
}
于 2018-11-02T18:17:21.953 回答