The shape of the layer’s shadow. Animatable.
- iOS 3.2+
- macOS 10.7+
- Mac Catalyst 13.0+
- tvOS 9.0+
- Core Animation
The default value of this property is
nil, which causes the layer to use a standard shadow shape. If you specify a value for this property, the layer creates its shadow using the specified path instead of the layer’s composited alpha channel. The path you provide defines the outline of the shadow. It is filled using the non-zero winding rule and the current shadow color, opacity, and blur radius.
Unlike most animatable properties, this property (as with all
CGPath animatable properties) does not support implicit animation. However, the path object may be animated using any of the concrete subclasses of
CAProperty. Paths will interpolate as a linear blend of the "on-line" points; "off-line" points may be interpolated non-linearly (to preserve continuity of the curve's derivative). If the two paths have a different number of control points or segments, the results are undefined. If the path extends outside the layer bounds it will not automatically be clipped to the layer, only if the normal layer masking rules cause that.
Specifying an explicit path usually improves rendering performance.
The value of this property is retained using the Core Foundation retain/release semantics. This behavior occurs despite the fact that the property declaration appears to use the default assign semantics for object retention.
Using Shadow Path for Special Effects
You can use a layer's shadow path to create special effects such as simulating the shadows available in Pages.
Listing 1 shows the code required to add an elliptical shadow to the bottom of a layer to simulate the Pages Contact Shadow effect.