Graphics Reference
In-Depth Information
Figure 5.11 The vanishing point
Core Animation defines the vanishing point as being located at the anchorPoint of the
layer being transformed (which is usually the center of the layer, but may not be—see
Chapter 3 for details). That is to say, it's located wherever the anchorPoint of the view
was positioned prior to applying the transform; if the transform includes a translation
component that moves the layer to somewhere else onscreen, the vanishing point will be
wherever it was located before it was transformed.
When you change the position of a layer, you also change its vanishing point. This is
important to remember when you are working in 3D. If you intend to adjust the m34
property of a layer to make it appear three-dimensional, you should position it in the center
of the screen and then move it to its final location using a translation (instead of changing
its position ) so that it shares a common vanishing point with any other 3D layers on the
screen.
The sublayerTransform Property
If you have multiple views or layers, each with 3D transforms, it is necessary to apply the
same m34 value to each individually and to ensure that they all share a common
position in the center of the screen prior to being transformed. This is relatively
straightforward if you define a constant or function to create and position them all for you,
but it is still restrictive (for example, it prevents you from arranging your views in Interface
Builder). There is a better way.
CALayer has another transform property called sublayerTransform . This is also a
CATransform3D , but instead of transforming the layer to which it is applied, it affects
only the sublayers. This means you can apply a perspective transform once and for all to a
single container layer, and the sublayers will all inherit that perspective automatically.
Search WWH ::




Custom Search