【问题标题】:Erase pdfAnnotation added using pdfkit擦除使用 pdfkit 添加的 pdfAnnotation
【发布时间】:2018-12-12 06:15:00
【问题描述】:

我使用下面的代码在 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)

【问题讨论】:

    标签: ios swift pdfkit pdf-annotations pdfpage


    【解决方案1】:

    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];
    

    【讨论】:

      猜你喜欢
      • 2018-10-01
      • 2021-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-27
      • 2020-12-11
      相关资源
      最近更新 更多