I want to pre-render some graphics into CGLayer
for fast drawing in future.
I found that CGLayerCreateWithContext
requires a CGContext
parameter. It can be easily found in drawRect:
method. But I need to create a CGLayer
outside of drawRect:
. Where should I get CGContext
?
Should I simply create temporary CGBitmapContext
and use it?
UPDATE: I need to create CGLayer outside of drawRect: because I want to initialize CGLayer before it is rendered. It is possible to init once on first drawRect call but it's not beautiful solution for me.