OGeek|极客世界-中国程序员成长平台

标题: ios - 删除 CGContextAddPath 之后的路径 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 14:34
标题: ios - 删除 CGContextAddPath 之后的路径

我想知道在我使用 CGContextAddPath 添加 CGPath 之后,是否有办法从我的上下文中删除它,这样我的绘图命令就不再局限于路径尺寸。



Best Answer-推荐答案


您应该使用 CGContextBeginPath(...) 从指定的上下文中删除之前添加的路径。

来自Apple's documentation的方法的讨论:

A graphics context can have only a single path in use at any time. If the specified context already contains a current path when you call this function, Quartz discards the old path and any data associated with it.

The current path is not part of the graphics state. Consequently, saving and restoring the graphics state has no effect on the current path.

类似于下面:

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextAddPath(context, ellipsePath);
CGContextDrawPath(context, kCGPathFill);

CGContextBeginPath(context);

CGContextAddPath(context, strokePath);
CGContextDrawPath(context, kCGPathStroke);

关于ios - 删除 CGContextAddPath 之后的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11366689/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4