从 PDF 查找批注点注释

  • 本文关键字:注释 PDF 查找 ios swift
  • 更新时间 :
  • 英文 :


我在视图中添加了一些注释。我现在要做的是从我的触摸位置使用 CGPoint 找到这些注释。这是我到目前为止得到的:

func annotationWithHitTest(at: CGPoint) -> PDFAnnotation? {
    for annotation in annotations {
        return annotation
    }
    return nil
}
因此,在我所有注释的

循环中,我试图找到最接近我的CGPoint的注释。我将如何实现这一点?

更新

我能够获得注释的CGPoint,

但是它大多与我的触摸位置的CGPoint不匹配,所以我会得到它以便找到壁橱物品吗?

func annotationWithHitTest(at: CGPoint) -> PDFAnnotation? {
        for annotation in annotations {
            print("Touch")
            print(at)
            print("Annotation")
            print(annotation.bounds.origin)
            return annotation
        }
        return nil
    }
--

已更新 -- 意识到这是针对 PDFAnnotation,而不是 UIView。

您可以使用 PDFAnnotation API 找到所选点。

https://developer.apple.com/documentation/pdfkit/pdfpage/1504793-annotation

最新更新