Graphics Programs Reference
In-Depth Information
Notice that layers interpret their size and position differently than views do. With a
UIView
, we typically define the
frame
of the view to establish its size and position. The
origin of the frame rectangle is the upper-left corner of the view, and the size stretches
right and down from the origin.
For a
CALayer
, instead of defining a frame, you set the
bounds
and
position
prop-
erties of the layer. The default setting for
position
is the
center
of the layer in its su-
perlayer. (The
anchorPoint
property determines where the position lies inside the lay-
er's bounds, and its default value is
(0.5, 0.5)
, otherwise known as the center.)
Therefore, if you change the size of the layer but leave the position constant, the layer will
remain centered on the same point.