Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Decorating Your Layers
A major advantage of CALayer over UIView, even if you’re only working in 2D, is the automatic border effects that CALayer provides. For instance, CALayer can automatically give you rounded corners, a colored border, and a drop shadow. All of these can be animated, which can provide some nice visual effects. For instance, you can adjust the position and shadow to give the illusion of clicking as the user presses and releases a layer. The following code will create the layer shown in Figure 7-4.
Figure 7-4 Layer with colored, rounded border and shadow.
DecorationViewController.m (Decoration)
CALayer *layer = [CALayer layer];
layer.frame = CGRectMake(100, 100, 100, 100);
layer.cornerRadius = 10;