I'm building an app to edit PDFs on iPad.
I'm trying to implement the dragging of the annotations with a panGesture recognizer that I added to the superview of the PDFView. The problem is that the new rect bounds of the annotation gets assigned but the changes doesn't reflect on screen.
Here is my code:
@objc func handlePanGesture(panGesture: UIPanGestureRecognizer) {
let touchLocation = panGesture.location(in: pdfView)
guard let page = pdfView.page(for: touchLocation, nearest: true) else {
return
}
let locationOnPage = pdfView.convert(touchLocation, to: page)
switch panGesture.state {
case .began:
guard let annotation = page.annotation(at: locationOnPage) else {
return
}
currentlySelectedAnnotation = annotation
case .changed:
guard let annotation = currentlySelectedAnnotation else {
return
}
let initialBounds = annotation.bounds
annotation.bounds = CGRect(origin: locationOnPage,
size: initialBounds.size)
print("move to \(locationOnPage)")
case .ended, .cancelled, .failed:
break
default:
break
}
}
Hope you can help me.