Graphics Programs Reference
In-Depth Information
The layer hierarchy, however, is a different story. Siblings are far more likely to overlap
because layers are about visual effects and drawing, not user interaction. Which sibling is
composited over the other? Each layer has a property called zPosition . If two layers
are siblings and they overlap, then the layer with the higher zPosition is composited
on top of the layer with the lower zPosition . (A sublayer always draws on top of its
superlayer, regardless of zPosition .)
A layer's zPosition defaults to 0 and can be set to a negative value.
[underLayer setZPosition:-5];
[overLayer setZPosition:5];
[parentLayer addSublayer:underLayer];
[parentLayer addSublayer:overLayer];
// overLayer is composited on top of underLayer!
When the Z-axis is discussed, some developers imagine that perspective is applied, and
they expect a layer to appear larger as its zPosition increases. However, Core Anima-
tion layers are presented orthographically; they do not appear as different sizes based on
their zPosition s.
Figure 22.6 Perspective vs. orthographic
Search WWH ::




Custom Search