3

我使用下面的代码在 pdfpage 上画了一条线。当用户拖动注释时,有什么方法可以像橡皮擦一样擦除注释。

let lineAttributes: [PDFAnnotationKey: Any] = [ .linePoints: [startPoint.x, startPoint.y, point.x, point.y],
            .lineEndingStyles: [PDFAnnotationLineEndingStyle.none,PDFAnnotationLineEndingStyle.none], .color: UIColor.red,.border: PDFBorder() ]
            let lineAnnotation = PDFAnnotation(bounds: pageBounds , forType: .line,withProperties: lineAttributes)
            lineAnnotation.border = border
            lineAnnotation.color = selectedcolor
            page!.addAnnotation(lineAnnotation)
4

1 回答 1

0

1) 将平移手势识别器添加到您的 PDFView

2)跟踪手势并在正确的时刻(如手势越过注释)调用page.removeAnnotation(lineAnnotation)

这就是如何从手势识别器获取页面内的触摸位置

CGPoint touchLocation = [sender locationInView:self.pdfView];
PDFPage * pdfPage = [self.pdfView pageForPoint:touchLocation nearest:NO];
if (pdfPage == nil) {
    return;
}

CGPoint pageLocation = [self.pdfView convertPoint:touchLocation toPage:pdfPage];
于 2019-02-07T14:36:46.150 回答