首页 > 解决方案 > 注释而不是在 PDFView 中选择文本

问题描述

我正在编写一个允许创建注释的 PDF 查看器。我已经想出了如何创建跨越当前选定文本的(标记)注释:

let pdfView = PDFView()
let selectionsByLine = pdfView.currentSelection.selectionsByLine()

for line in selectionsByLine {
    for page in line.pages {
        let bounds = line.bounds(for: page)
        let annotation = PDFAnnotation(bounds: bounds,
                                       forType: .highlight,
                                       withProperties: [:])
        page.addAnnotation(annotation)
    }
}

但我想允许用户通过选择它来选择一个工具和标记文本。到目前为止,我已经想到了两种方法:

我对 UIKit 不太熟悉,所以我希望有人能指出我正确的方向:D

标签: swiftuikituigesturerecognizerios-pdfkitapple-pdfkit

解决方案


推荐阅读