Graphics Reference
In-Depth Information
[ super viewDidLoad ];
//set the corner radius on our layers
self .layerView1. layer . cornerRadius = 20.0f ;
self .layerView2. layer . cornerRadius = 20.0f ;
//enable clipping on the second layer
self .layerView2. layer . masksToBounds = YES ;
}
@end
Figure 4.2 The red subview on the right is clipped to the cornerRadius of its superview.
As you can see, the red view on the right is clipped to the curve of its superview.
It is not possible to control the curvature of each layer corner independently, so if you want
to create a layer or view that has some sharp and some rounded corners, you'll need to find
a different approach, such as using a layer mask (as covered later in the chapter) or
CAShapeLayer (see Chapter 6, “Specialized Layers”).
Search WWH ::




Custom Search