I'm trying to get my head around Core Graphics and Core Animation. I understand the following:
UIView
, I can draw with Core Graphics by overriding drawRect
.CALayer
's and set their properties and have them addedMy questions are:
- If I create a CALayer
from scratch (not using something like CALayer *myLayer = myUIView.layer
), what is the approach to draw in that CALayer
?
- What's the CALayer's equivalent of drawRect
for UIView?
I hope that makes sense.
To do custom drawing you have two options:
CALayer
and implement -drawInContext:
.-drawLayer:inContext:
.You should add your custom layer as a sublayer to your UIView
's layer. You should take a spin through CALayer
's doc pages for some rules about how to interact with the view's layer.