完成绘制后清除CGPath路径 [英] Clearing CGPath path after drawing is done

查看:63
本文介绍了完成绘制后清除CGPath路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个用于在iOS中使用touchesMoved()方法绘图的程序。

I've written a program for drawing in iOS in touchesMoved() method.

CGContextAddPath(UIGraphicsGetCurrentContext(), path);
CGPathMoveToPoint(path, NULL, lastPoint.x, lastPoint.y);
CGPathAddLineToPoint(path, NULL, lastPoint.x, lastPoint.y);
CGContextDrawPath(UIGraphicsGetCurrentContext(), kCGPathStroke);

我如何清除绘制的路径并恢复原始视图?

How can i clear the path drawn and restore the original view?

推荐答案

也许您可以在图形视图上方放置一个不可见的视图,并仅当您确定用户不会撤消时才添加用户跟踪的路径。如果用户想要撤消操作,请不要将路径添加到上下文中。那是我的逻辑。我不确定该如何加以限制。
希望这会有所帮助。

Perhaps you can put an invisible view above your view of drawing and add the path traced by the user only when u are sure that the user will not undo. If the user wants the undo action, don't add the path to the context. Thats my logic. I am not sure how it can be implemted. Hope this helps.

这篇关于完成绘制后清除CGPath路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆