1

我在某处看到此代码用于突出显示 pdf 文档中的选定文本:

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

为了我 ,

让选择 = pdfView.currentSelection?.selectionsByLine()

总是给零。把这段代码放在哪里。我把它放在手势识别器委托方法中。

此外,它似乎在页面上添加了多个注释。我们是否会在页面上的每个选择中获得单个突出显示注释?

4

0 回答 0