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 que
The lightest-wight solution would be to create a small helper class in the the file as the UIView that's using the CALayer:
In MyView.h
@interface MyLayerDelegate : NSObject
. . .
@end
In MyView.m
@implementation MyLayerDelegate
- (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)ctx
{
. . .
}
@end
Just place those at the top of your file, immediately below the #import directives. That way it feels more like using a "private class" to handle the drawing (although it isn't -- the delegate class can be instantiated by any code that imports the header).