ios - 通过 CGContext 函数(CGContextAddArc 等)与 CGPath 函数(CGPathAddArc 等)绘图之间的区别

标签 ios core-graphics quartz-graphics

我知道,如果您使用 CGPath 函数进行绘制,您无论如何都必须在最后将该 CGPath 添加到 CGContext (CGContextAddPath),但是选择第一种方法比第二种方法有什么优势/劣势吗?是的,我知道您也可以使用 UIBezierPath 进行绘图,而且我知道 CGPath 之间的区别。

最佳答案

因此,通过 UIBezierPath 上的文档,我发现了通过 CGContext 函数进行绘图的优势之一:

The advantage of modifying the graphics context (as opposed to the path object itself) is that you can easily undo the transformation by saving and restoring the graphics state. UIBezierPath documentation

我想出的另一个方法是,如果您通过 CGContext 函数绘制,则不必释放路径 (CGPathRelease)。

关于ios - 通过 CGContext 函数(CGContextAddArc 等)与 CGPath 函数(CGPathAddArc 等)绘图之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36309166/

相关文章:

ios - Objective-C:单步执行 double* 数组时 EXC_BAD_ACCESS code=2

ios - iOS 会允许来自蓝牙外围设备的警报吗?

ios - 当我返回应用程序时相机被卡住(Obj-C)

ios - SKNode线程安全吗?

c++ - 在 OSX 中以编程方式抓取屏幕截图

iphone - 有哪些很棒的 Quartz 2D 绘图教程?

objective-c - CGContext 的静态背景

ios - "CGLayer no longer recommended";这是普遍共识吗?

ios - 填充后无法描边路径

iphone - 描边同时应用于文本和阴影