我想知道在使用 CGContextAddPath 添加 CGPath 后是否有办法从上下文中删除 CGPath,以便之后我的绘图命令不再局限于路径尺寸。
最佳答案
您应该使用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/