If I create a subclassed UIView
and want to use a bunch of custom made content (animations via CABasicAnimation
using CAShapeLayer
s, custom made drawings using CGContextRef
in drawRect
) when is the right time to create, add and animate sublayers?
I know that I should perform custom drawings in the drawRect
method (and since there is the only place when I can actually get UIGraphicsGetCurrentContext()
that kinda narrows my choice down). Now I have been creating sublayers, animations and all that other non-drawing related stuff in the drawRect
as well. But I'm not sure that drawRect
is the best place to do those kind of activities.
I am familiar with layoutSubviews
method and some other UIView
methods but haven't actually implemented any of them except drawRect
.
So if I repeat myself one more time - the question goes: Where to add sublayers, where to animate them and are there any tricks or catches I should be aware of?