Using CALayer Delegate

Posted by Shaun Budhram on Stack Overflow See other posts from Stack Overflow or by Shaun Budhram
Published on 2010-01-06T18:48:36Z Indexed on 2010/03/22 3:41 UTC
Read the original article Hit count: 901

Filed under:
|

I have a UIView whose layers will have sublayers. I'd like to assign delegates for each of those sublayers, so the delegate method can tell the layer what to draw. My question is:

What should I provide as CALayer's delegate? The documentation says not to use the UIView the layers reside in, as this is reserved for the main CALayer of the view. But, creating another class just to be the delegate of the CALayers I create defeats the purpose of not subclassing CALayer. What are people typically using as the delegate for CALayer? Or should I just subclass?

Also, why is it that the class implementing the delegate methods doesn't have to conform to some sort of CALayer protocol? That's a wider overarching question I don't quite understand. I thought all classes requiring implementation of delegate methods required a protocol specification for implementers to conform to.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about calayer