开发者

Render layer offscreen

How can I create/prepare a CALayer offscreen, so that when the page is displayed, then all it has to do is to display the开发者_如何学运维 prepared layer?


Render your content into an CGBitmapContext, pull a CGImageRef off of that and set that as the contents of the CALayer. Take a look at Creating a Bitmap Graphics Context for example code for most of this.

But if your real problem is that your drawInContext: is too slow, you should first look at breaking that up so that you pre-calculate everything when the data changes and only do drawing in drawInContext:. This is generally the better approach. Don't pre-render the layer itself; pre-calculate everything you need to render the layer quickly. But for very complicated drawing, the CGImageRef approach is useful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜