objective-c - Objective-C : How to use CGLayerCreate and CGContextDrawLayerAtPoint?

标签 objective-c ios xcode ipad core-graphics

我正在研究 Core Graphics 来为我的项目制作动态纹理。

一个 friend 告诉我应该使用 CGLayerCreate 和 CGContextDrawLayerAtPoint 改进我正在构建的画笔应用程序的纹理,但我还没有找到任何包含 CGLayerCreate 和 CGContextDrawAtPoint 的书籍或教程。

你们能告诉我这两个有什么用吗?如何编写它们?

另外,如果您知道任何包含这些内容的核心图形书籍,请告诉我,它一定会对我有所帮助。

谢谢!

最佳答案

Quartz 2D Programming Guide有一章讨论 CGLayer 对象。

你的 friend 可能会想到层的这种用法,引用那一章:

Repeated drawing. For example, you might want to create a pattern that consists of the same item drawn over and over. Draw the item to a layer and then repeatedly draw the layer, as shown in Figure 12-1. Any Quartz object that you draw repeatedly—including CGPath, CGShading, and CGPDFPage objects—benefits from improved performance if you draw it to a CGLayer. Note that a layer is not just for onscreen drawing; you can use it for graphics contexts that aren’t screen-oriented, such as a PDF graphics context.

Quartz2DBasics 中还有一个非常非常简单的示例示例应用程序。

关于objective-c - Objective-C : How to use CGLayerCreate and CGContextDrawLayerAtPoint?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8132987/

相关文章:

ios - AVPlayer 无法播放上传到服务器的.mov

ios - 无法使用 UIActivityViewController 以 NSDATA 的形式共享 Docx

ios - Phonegap Cordova 插件在构建时删除

ios - 访问 obj 作为属性与方法参数(样式首选项)

ios - 使用 AFNetworking 3.0 从下一个 View Controller 发送特定参数以响应服务器?

iphone - 难以理解通用应用程序、多个 View Controller

ios - 使用 LUA 的 Cocos2dx iOS 项目

xcode - 如何在XCode中安装以前的iOS版本(仅iOS 4.3可见)

ios - UITableView cellForRowAtIndexPath 没有被调用

objective-c - 如何在 Objective-C header 中引用 Swift 枚举