Extract your content into the CGBitmapContext, pull out the CGImageRef and set it as the contents of the CALayer. See Creating a bitmap graphic context , for example, the code for most of this.
But if your real problem is that yours is drawInContext:too slow, you must first deal with this so that you can pre-calculate everything when the data changes, and only draws in drawInContext:. This is usually the best approach. Do not pre-render the layer; pre-compute everything you need to quickly render the layer. But for very complex drawing it is useful to use the CGImageRef approach.
source
share