Удалить pdfAnnotation добавлено с помощью pdfkit - PullRequest
0 голосов
/ 12 декабря 2018

Я использовал приведенный ниже код, чтобы нарисовать линию на pdf-странице.Можно ли как-нибудь стереть аннотацию, как ластик, когда пользователь перетаскивает ее?

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 Ответ

0 голосов
/ 07 февраля 2019

1) добавьте распознаватель жестов панорамирования в PDFView

2) отслеживайте жест и в нужный момент (как жест переходит к аннотации) вызовите page.removeAnnotation(lineAnnotation)

thisкак вы можете получить местоположение касания внутри страницы из распознавателя жестов

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