CoreGraphics: Using finger strokes to erase part of image?

倖福魔咒の 提交于 2019-12-04 14:55:45

You don't have to use CGContextClearRect to clear strokes.

Instead do CGContextSetBlendMode(context, kCGBlendModeClear)

This call changes the color blending mode in such a way that drawing operations would be clearing bitmap instead of drawing with color.

Then you can just draw lines which connect touch locations so that there are no gaps.

To switch back to normal rendering do CGContextSetBlendMode(context, kCGBlendModeNormal)

Using different blending modes can be very helpful.

You should never do anything but drawing in your drawRect code. That really slows down the process. Instead, think of perhaps splitting off rendering to a separate thread. That will really speed things up.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!