如何用png-brush和UIBezierPath擦除UIImageView片段

Max*_*lov 6 iphone core-graphics ios

我有两个UIImageView,第一个超过第二个.我想用画笔擦除第一张图像的一部分(画笔是带软边缘的png图片),以使第二张图像的一部分可见.

我这样做了:

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

2)at (void)drawRect:(CGRect)rect我调用[_brush drawAtPoint:touch_location blendMode:kCGBlendModeDestinationOut alpha:1];

它工作正常,但频率touchesMoved不够,如果用户移动手指太快然后我得到了很多的短线(或平衡点),而不是一个长行.

我找到了UIBezierPath和示例的信息,但作者只是按路径绘制线条:

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextAddPath(context, path);

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

CGContextStrokePath(context);
Run Code Online (Sandbox Code Playgroud)

如何用UIBezierPath绘制我的png画笔?

我需要这样的东西

在此输入图像描述

非常感谢!

Ama*_*mar 2

有一个开源项目对您有用.. iOS-Scratch-n-See。课程ImageMaskView学习起来会很有趣。

希望有帮助!