Graphics Reference
In-Depth Information
6
Specialized Layers
Specialization is a feature of every complex organization.
Catharine R. Stimpson
Up to this point, we have been working with the CALayer class, and we have seen that it
has some useful image drawing and transformation capabilities. But Core Animation layers
can be used for more than just images and colors. This chapter explores some of the other
layer classes that you can use to extend Core Animation's drawing capabilities.
CAShapeLayer
In Chapter 4, “Visual Effects,” you learned how to use CGPath to create arbitrarily shaped
shadows without using images. It would be neat if we could create arbitrarily shaped layers
in the same way.
CAShapeLayer is a layer subclass that draws itself using vector graphics instead of a
bitmap image. You specify attributes such as color and line thickness, define the desired
shape using a CGPath , and CAShapeLayer renders it automatically. Of course, you
could use Core Graphics to draw a path directly into the contents of an ordinary CALayer
(as in Chapter 2, “The Backing Image”), but there are several advantages to using
CAShapeLayer instead:
It's fast CAShapeLayer uses hardware-accelerated drawing and is much faster
than using Core Graphics to draw an image.
It's memory efficient —A CAShapeLayer does not have to create a backing image
like an ordinary CALayer does, so no matter how large it gets, it won't consume
much memory.
 
 
Search WWH ::




Custom Search