6

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

我是这样做的:

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

2) 在(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);

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

我需要这样的东西

在此处输入图像描述

非常感谢!

4

1 回答 1

2

有一个对您有用的开源项目 .. iOS-Scratch-n-See。上课ImageMaskView会很有趣。

希望有帮助!

于 2013-07-16T13:00:29.497 回答