Currently i am adding the changes as subview to the original image. I want to add an eraser tool so that when the user draws on the screen, the subviews will be cleared and the underlined image will be seen . Same as an eraser tool in "Paint".Below is the code used for drawing a rectangle.How can i add an eraser tool using the same method. Thank you
case 2:
let path = UIBezierPath()
let sh = CAShapeLayer()
sh.strokeColor = selectedcolor.cgColor
sh.lineWidth = 3
sh.fillColor = UIColor.clear.cgColor
tempImage.layer.sublayers?.removeAll()
sh.fillColor = UIColor.clear.cgColor
path.move(to: startPoint)
sh.path = UIBezierPath(rect: rect).cgPath
tempImage.layer.addSublayer(sh)
if usermoving == 0
{
sh.setValue(tag, forKey: "tag")
mainImage.layer.addSublayer(sh)
}
break