user1529476
user1529476

Reputation:

iOS Label Shadowing

I have this code here,

label.layer.shadowColor = [UIColor orangeColor].CGColor;
label.layer.shadowOffset = CGSizeMake(0,1);
label.layer.shadowRadius = 3.0;
label.layer.shadowOpacity = 0.5;
label.layer.shadowPath = [[UIBezierPath bezierPathWithRoundedRect:label.frame cornerRadius:20]CGPath];

I am using orange for testing purposes. Why is this not appearing as a shadow? All I am seeing is this, http://img12.imageshack.us/img12/1568/screenshot20130312at415.png

I am trying to get the gray label on the inside to have a shadow around the edges... Any help?

-Henry

Upvotes: 0

Views: 170

Answers (2)

nsgulliver
nsgulliver

Reputation: 12671

Try setting shadowOffset -1

label.layer.shadowOpacity = 1.0;
label.layer.shadowRadius =2.0;
label.layer.shadowColor = [UIColor blackColor].CGColor;
label.layer.shadowOffset = CGSizeMake(0.01,-1.0);

Also set label.bounds instead of label.frame

label.layer.shadowPath = [[UIBezierPath bezierPathWithRoundedRect:label.bounds cornerRadius:20]CGPath];

Upvotes: 1

rob mayoff
rob mayoff

Reputation: 385860

You need to use label.bounds, not label.frame, to create the path. Also, make sure label.clipsToBounds is NO.

Upvotes: 2

Related Questions