使用 UIBezierPath 擦除线条图
使用 UIBezierPath 做了一个简单的线条绘制应用程序,但现在需要一种方法来擦除用 UIBezierPath 绘制的线条。有没有办法实现橡皮擦功能来删除线条画?
Did a simple application for line drawing with UIBezierPath, but now need a way to erase the line drawn with UIBezierPath. Is there a way to implement eraser feature for removing the line painting?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用图像作为背景,那么您可以将相同的图像设置为画笔图案来绘制贝塞尔路径,它实际上会给您带来橡皮擦效果。这对我有用。 :)
If you are using an image as background then you can set the same image as brush pattern to draw the bezierpath it will virtually give you the eraser effect. It works for me. :)
橡皮擦可以有效地在迄今为止绘制的每条路径上绘制一条与背景颜色相同的线。您可能需要注意,它是某处的橡皮擦线,以便您可以在背景颜色发生变化时更新橡皮擦线的描边颜色,否则您会失去擦除的错觉。
An eraser effectively draws a line that's the same color as the background atop every path that's been drawn thus far. You might need to note that it's an eraser line somewhere so that you can update the eraser line's stroke color if the background color changes, otherwise you lose the illusion of erasure.
根据您对杰里米答案的评论,您似乎正在尝试做虚线。您是否尝试过使用 setLineDash:count:phase:
Apple 有示例代码这里: http://developer.apple.com/library/ mac/#samplecode/BezierPathLab/Introduction/Intro.html
Based on your comments on Jeremy's answer, it seems like you're trying to do dashed lines. Have you tried using setLineDash:count:phase:
Apple has sample code here: http://developer.apple.com/library/mac/#samplecode/BezierPathLab/Introduction/Intro.html