June 2011
Intermediate to advanced
590 pages
19h 31m
English
In this chapter, you set a layer’s contents with an image file. Now let’s look at setting a layer’s contents programmatically. There are two ways of drawing to a layer that use Core Graphics: subclassing and delegation.
In practice, subclassing is the last thing you want to do. The only reason to subclass CALayer to provide custom content is if you need to draw differently depending on some state of the layer. If this is the approach you wish to take, you must override the method drawInContext:.
@implementation LayerSubclass - (void)drawInContext:(CGContextRef)ctx { UIImage *layerImage = nil; ...Read now
Unlock full access