The View Programming Guide for iOS on pg. 57 has this piece of code:
// Create the layer.
CALayer* myLayer = [[CALayer alloc] init];
// Set the contents of the layer to a fixed image. And set
// the size of the layer to match the image size.
UIImage layerContents = [[UIImage imageNamed:@"myImage"] retain];
CGSize imageSize = layerContents.size;
myLayer.bounds = CGRectMake(0, 0, imageSize.width, imageSize.height);
myLayer = layerContents.CGImage;
Why would you want to do this in the last line: myLayer = layerContents.CGImage;. For one thing, the objects don’t match up so it’s a type problem. But it’s replacing the object created in the first statement!
What am I missing?
Looks like that document is wrong. It should probably be:
This is one way to set the contents of a layer. See the docs for
contents