How to erase piece of UIImageView with png-brush and UIBezierPath

不问归期 提交于 2019-12-18 13:39:07

问题


I have two UIImageView, first above second. I want to erase piece of the first image with brush (brush is a png picture with soft edge) to make piece of the second image visible.

I did that by this way:

1) touchesMoved and [self setNeedsDisplayInRect:[self brushRectForPoint:touch_location]];

2) at (void)drawRect:(CGRect)rect I call [_brush drawAtPoint:touch_location blendMode:kCGBlendModeDestinationOut alpha:1];

It works ok, but frequency of touchesMoved not enough, if user moves finger too fast then I get a lot of short lines (or even points) instead of one long line.

I found information of UIBezierPath and example but author just draws lines by path:

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextAddPath(context, path);

CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context, self.lineWidth);
CGContextSetStrokeColorWithColor(context, self.lineColor.CGColor);

CGContextStrokePath(context);

How I can draw my png brush with UIBezierPath?

I need something like this

Thanks a lot!


回答1:


There is an open source project which will be useful for you .. iOS-Scratch-n-See. Class ImageMaskView will be interesting to study.

Hope that helps!



来源:https://stackoverflow.com/questions/17674311/how-to-erase-piece-of-uiimageview-with-png-brush-and-uibezierpath

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