Graphics Reference
In-Depth Information
In this final piece, we initialize a new
ReplicatorView
with a
frame
the same size as the
application itself and add it to the window. The image to be displayed is loaded into a
UIImageView
, and the
-contentMode
of that
UIImageView
is set so that it scales the image
to fit the frame. Finally, the
UIImageView
is added to the instance of the
ReplicatorView
.
If you wanted to add more than one component to the
ReplicatorView
, you would need
to adjust the
instanceCount
appropriately so that each sublayer added has one replicated
layer.
Each of
CALayer
's subclasses are very useful on their own. However, they can be applied
together and along with other
CALayer
subclasses to provide some startling effects. For
example, a combination of
CAReplicatorLayer
and
CAShapeLayer
can produce a perfectly
aligned pie chart with identically sized wedges.
In the next chapter, we discuss how to add user interaction to Core Animation layers. The
combination of
CAShapeLayers
with User Interaction can create dazzling user interfaces
that go beyond the standard widgets that both the Desktop and iPhone offer.