Graphics Reference
In-Depth Information
Figure 4.10 The view on the right now has a shadow, despite clipping.
The shadowPath Property
We've established that layer shadows are not always square, but instead derive from the
shape of the contents. This looks great, but it's also very expensive to calculate in real time,
especially if the layer contains multiple sublayers, each with alpha-masked backing images.
If you know in advance what the shape of your shadow needs to be, you can improve
performance considerably by specifying a shadowPath . The shadowPath is a
CGPathRef (a pointer to a CGPath object). CGPath is a Core Graphics object used to
specify an arbitrary vector shape. We can use this to define the shape of our shadow
independently of the layer's shape.
Figure 4.11 shows two different shadow shapes applied to the same layer image. In this
case, the shapes we've used are simple, but they can be absolutely any shape you want. See
Listing 4.4 for the code.
Search WWH ::




Custom Search