Graphics Reference
In-Depth Information
The reason is because there is a significant difference between scaling a layer and changing
its bounds . When a layer is scaled, the layer still thinks it is the original size and draws
itself at the original size before the scale is applied. However, if we change the bounds and
then scale the layer, the layer won't look quite right because it knows it is a different size.
For example, if we changed the layer's bounds in the “Combining Transforms” example
instead of doing a scale transform, the end result of the animation would look like
Figure 5-4.
FIGURE 5-4
Bounds and Rotation Animation
Notice that the end layer looks like a circle. This is because we changed the bounds of the
layer but did not change the corner radius or the border width. However, when a scale
transform is used, the result has the effect we're looking for, as shown in Figure 5-5.
This gives you a square. One thing you notice when looking at Figure 5-5 is that the
border isn't visible; this is because the scaled border is less than 0.5 pixels. Also, because
the corner radius (originally 5 pixels) is less than 1 pixel, it also is no longer visible. When
working with a complex layer tree, the difference between changing the bounds and the
scale can be quite dramatic. If we had scaled this layer up by 100 percent, the border
would be 50 pixels wide!
Search WWH ::




Custom Search