UIGraphicsBeginImageContext
是否使用CGBitmapContextCreate
创建图形上下文[更新:我在文档中找不到],所以图形上下文是完全一样的吗?我还尝试进入 UIGraphicsBeginImageContext
但调试器不允许我进入。
最佳答案
在UIKit Function References iOS文档页面,下面是关于UIGraphicsBeginImageContext
的写法:
Creates a bitmap-based graphics context and makes it the current context.
添加了强调。通过指向 CGContextRef 的链接页面,我发现这个:
A graphics context contains drawing parameters and all device-specific information needed to render the paint on a page to the destination, whether the destination is a window in an application, a bitmap image, a PDF document, or a printer.
再次强调。这表示(截至目前)有 4 种 Core Graphics 上下文,每种都有自己的初始化器。唯一与位图有关的是基于位图的 CGContextRef,并且只有一种记录的方法来创建它们(好吧,从技术上讲,它有两个版本)。很有可能正在使用这个功能。我相信 UIGraphicsBeginImageContext
只是一种方便的方法。它只是为 CGBitmapContextCreate 设置一组默认参数(它需要很多参数)并将创建的上下文推送到图形堆栈上。
关于ios - 确定 UIGraphicsBeginImageContext 使用 CGBitmapContextCreate 创建图形上下文吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10829226/