我用下面的代码来画一条线到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)
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];