Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone - How to control CALayer's shadow, exactly?

I am very new to CALayer thing. I had a look at the documentation, but quite don't understand the meaning of those properties which can be used to control the shadow

shadowOpacity

shadowRadius

shadowOffset

I particularly don't understand the Offset & Radius.

Can anyone give me some lights to me, for this newbie question?

Another question about the shadow is

If the UIView view1's frame is CGRect(0, 0, 768, 40), if I apply shadow on it, will the shadow possibly be covered by another UIView which is just next to the bottom edge of view1?

thanks

like image 737
Jackson Tale Avatar asked Jun 28 '11 14:06

Jackson Tale


1 Answers

The offset is how far the shadow is cast from its view. The radius is how blurry it is. You could set an offset that is zero CGSizeMake(0,0) and a radius of 5.0 and you would have an even shadow around your view.

Remember to import the QuartzCore library when trying to work with CALayers.

The shadow may be covered by views that are above it in the view heiarchy.

like image 151
Dancreek Avatar answered Sep 19 '22 15:09

Dancreek