【发布时间】:2013-07-16 10:36:33
【问题描述】:
我有两个 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 和 example 的信息,但作者只是按路径画线:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextAddPath(context, path);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context, self.lineWidth);
CGContextSetStrokeColorWithColor(context, self.lineColor.CGColor);
CGContextStrokePath(context);
如何使用 UIBezierPath 绘制我的 png 画笔?
我需要这样的东西
非常感谢!
【问题讨论】:
-
触摸位置的移动平均线怎么样?这将引入一些滞后(这可能是可取的,也可能不是可取的),但会消除“跳跃”。 MA 周期越长,越平滑,但滞后也越大。
-
好的,我明白了,但是当然延迟不好。无论如何感谢你的想法。也许我会尝试对此做点什么。
标签: iphone ios core-graphics