Hello,
currently I am building an UIView in which I'd like to draw over an image.
So far I got the drawing part done like so:
@objc private func didPanWhiteboard(_ gesture: UIPanGestureRecognizer) {
let location = gesture.location(in: drawCanvasView)
switch gesture.state {
case .began:
path = UIBezierPath()
path.move(to: location)
strokeLayer = CAShapeLayer()
drawCanvasView.layer.addSublayer(strokeLayer)
strokeLayer.strokeColor = toolColor.cgColor
strokeLayer.fillColor = UIColor.clear.cgColor
strokeLayer.lineWidth = toolWidth
strokeLayer.lineJoin = .round
strokeLayer.lineCap = .round
strokeLayer.path = path?.cgPath
case .changed:
path.addLine(to: location)
strokeLayer.path = path.cgPath
case .cancelled, .ended: drawLayers.append(strokeLayer)
default: break
}
}
using a pan gesture.
Now my problem is that I'd like to have an erase tool for my drawing but I am not sure at all on how to actually erase parts of the stroke.