MDCShadowLayer

@interface MDCShadowLayer : CALayer

The Material shadow effect.

@see https://material.io/guidelines/what-is-material/elevation-shadows.html#elevation-shadows-shadows

Consider rasterizing your MDCShadowLayer if your view will not generally be animating or changing size. If you need to animate a rasterized MDCShadowLayer, disable rasterization first.

For example, if self’s layerClass is MDCShadowLayer, you might introduce the following code:

self.layer.shouldRasterize = YES;
self.layer.rasterizationScale = [UIScreen mainScreen].scale;
  • The elevation of the layer in points.

    The higher the elevation, the more spread out the shadow is. This is distinct from the layer’s zPosition which can be used to order overlapping layers, but will have no affect on the size of the shadow.

    Negative values act as if zero were specified.

    The default value is 0.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) MDCShadowElevation elevation;
  • Whether to apply the cutout shadow layer mask.

    If enabled, then a mask is created to ensure the interior, non-shadow part of the layer is visible.

    Default is YES. Not animatable.

    Declaration

    Objective-C

    @property (getter=isShadowMaskEnabled, assign, readwrite, nonatomic)
        BOOL shadowMaskEnabled;
  • Animates the layer’s corner radius

    Note

    At the end of the animation the corner radius is set to your desired corner radius.

    Declaration

    Objective-C

    - (void)animateCornerRadius:(CGFloat)cornerRadius
             withTimingFunction:(nonnull CAMediaTimingFunction *)timingFunction
                       duration:(NSTimeInterval)duration;

    Parameters

    cornerRadius

    The desired corner radius at the end of the animation

    timingFunction

    The timing function you desire for the animation

    duration

    The duration of the animation