ios - 确定 UIGraphicsBeginImageContext 使用 CGBitmapContextCreate 创建图形上下文吗?

标签 ios cocoa-touch uikit core-graphics graphicscontext

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/

相关文章:

ios - 如何使用 mpmovieplayercontroller 打开 dailymotion 中的视频

ios - 是否可以为 UIViewController 的标题设置 UILineBreakMode 或等效项?

iphone - 如何调整 UITableView 的 tableHeaderView 的大小?

ios - UIBarButtonItem 是否支持带有自定义 View 的纵向和横向尺寸?

uinavigationcontroller - 当 UINavigationController 以模态呈现时 UIBarButtonItems 移动位置

php - 从 iOS 应用程序将多部分图像上传到 PHP 服务器

ios - 堆栈 View 动画 - 折叠排列的 subview

iphone - 如何在不打开应用程序的情况下更改应用程序图标?

iphone - 如何限制 5 个 UITextFields 中的字符数量

ios - UITableView 底部分隔符插图 - IOS 7 中的奇怪行为