Graphics Reference
In-Depth Information
@end
@implementation
ViewController
- (
void
)viewDidLoad
{
[
super
viewDidLoad
];
//create sublayer
CALayer
*blueLayer = [
CALayer
layer
];
blueLayer.
frame
=
CGRectMake
(
50.0f
,
50.0f
,
100.0f
,
100.0f
);
blueLayer.
backgroundColor
= [
UIColor
blueColor
].
CGColor
;
//add it to our view
[
self
.
layerView
.
layer
addSublayer
:blueLayer];
}
@end
Figure 1.5
A small blue
CALayer
nested inside a white
UIView
A view has only one
backing
layer (created automatically) but can
host
an unlimited
number of additional layers. As Listing 1.1 shows, you can explicitly create standalone
layers and add them directly as sublayers of the backing layer of a view. Although it is