Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIView with shadow

I'm trying to create a shadow around a simple UIView object which is added on top of a UIViewController's view. what's the most straight forward way of doing this?

like image 484
zumzum Avatar asked Feb 03 '11 15:02

zumzum


1 Answers

First, be sure to import the Quartz Core library:

#import <QuartzCore/QuartzCore.h>

Next, add the following lines to set up the shadow's properties:

someView.layer.shadowColor = [[UIColor blackColor] CGColor];
someView.layer.shadowOffset = CGSizeMake(10.0f,10.0f);
someView.layer.shadowOpacity = .5f;
someView.layer.shadowRadius = 10.0f;

Keep in mind that if you have that view's clipsToBounds property set to YES, the shadow won't appear.

like image 61
Ned Avatar answered Feb 07 '23 15:02

Ned