Graphics Reference
In-Depth Information
Only having to set the perspective transform in one place is convenient in itself, but it also
carries another significant benefit: The vanishing point is set as the center of the container
layer, not set individually for each sublayer. This means that you are free to position the
sublayers using their position or frame instead of having to set them all to the center
of the screen and move them with transforms to keep their vanishing point consistent.
Let's demonstrate this with an example. We'll place two views side by side in Interface
Builder (see Figure 5.12). Now by setting the perspective transform on their containing
view, we can apply the same perspective and vanishing point to both of them. See Listing
5.6 for the code and Figure 5.13 for the result.
Figure 5.12 Two views arranged side by side within a container view
Listing 5.6 Applying a sublayerTransform
@interface ViewController ()
@property ( nonatomic , weak ) IBOutlet UIView *containerView;
@property ( nonatomic , weak ) IBOutlet UIView *layerView1;
@property ( nonatomic , weak ) IBOutlet UIView *layerView2;
@end
@implementation ViewController
Search WWH ::




Custom Search