i'm struggling creating a drop shadow around a CALayer. For the effect i'm trying to achieve i need to have access to the "intensity" of the shadow. Somehow like the "spread" slider in Photoshop's Layer Styles. I think the "ShadowRadius" property of CALayer is equivalent to Photoshop's "Size" slider.
Any suggestions? Is maybe a radial gradient an option?
shadowRadius : the blur radius used to render the layer's shadow. A value of zero creates a hard-edged shadow that exactly matches the shape of the view. A larger value creates a soft-edged shadow that looks more natural. The default value of this property is 3.0 .
shadowColor sets the color of the shadow, and needs to be a CGColor . shadowOpacity sets how transparent the shadow is, where 0 is invisible and 1 is as strong as possible. shadowOffset sets how far away from the view the shadow should be, to give a 3D offset effect. shadowRadius sets how wide the shadow should be.
The layer's shadow uses several elements: shadowOffset , shadowColor , shadowOpacity , and shadowRadius . Each element changes the respective appearance. You can offset the shadow differently to change the direction the shadow is cast - how far from the layer and in which direction.
The blur radius (in points) used to render the layer's shadow.
Set the layer's shadowOffset
,shadowOpacity
, and shadowRadius
and you should have what you are looking for. Try this for a shadow project directly "underneath" the layer with a blur of 5 pixels, which with the right color, could also make it look like a glow:
CALayer *layer = myView.layer;
layer.shadowOpacity = 0.50;
layer.shadowRadius = 5.0;
layer.shadowOffset = (CGSize){.width=0.0,.height=0.0};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With