SKInnerShadowLayer is a
CAGradientLayer subclass that adds properties to create an inner shadow on a given layer.
SKInnerShadowLayer takes the graphical properties of a
CAGradientLayer that let you set the shadow, gradient, and border of a layer, and adds four properities that let you control the look of an inner shadow for the layer.
These properties are:
@property CGColorRef innerShadowColor; @property CGSize innerShadowOffset; @property CGFloat innerShadowRadius; @property CGFloat innerShadowOpacity;
They behave similarly to their drop shadow counterparts.
The technique for drawing the inner shadow is simple. The layer:
and this creates the illusion of an inner shadow.
These properties are all fully animatable. There is an example of a layer with an inner shadow opacity animation in the demo app. Being able to easily create animations is the immediate advantage of using
CoreGraphics to draw an inner shadow instead of using an image resource.