How can I erase UIBezierPath lines drawn on a transparent view above an image?

后端 未结 2 399
慢半拍i
慢半拍i 2020-12-17 07:23

I am creating an app like whiteboard application. I have one dynamic image. Image has multiple colors. I want to draw line on that Image same as whiteboard so I had overlap

相关标签:
2条回答
  • 2020-12-17 07:57

    You can use blend mode. Use CGBlendMode..Clear Document

    0 讨论(0)
  • 2020-12-17 08:09

    If you have an image in the background, and the image is the same size and origin as your whiteboard drawing canvas, you could try drawing your "erase" lines using the background image as a colour pattern:

    [[UIColor colorWithPatternImage:backgroundImage] set];
    

    Where backgroundImage is the UIImage that you are drawing on top of.

    This will overpaint your drawn lines with the image underneath, so it will appear that they are erased. It seems a bit hacky, though?

    0 讨论(0)
提交回复
热议问题