Reputation: 32091
I'm trying to add a shadow to a UIButton layer, but for some reason it cuts off at the bounds of the button. I set clipsToBounds is turned off, so I'm not sure why it's looking like this:
It's square, just like that, even though the shadow should not be squared..it should be soft and fading.
button.clipsToBounds = NO;
button.layer.masksToBounds = NO;
button.layer.shadowOffset = CGSizeZero;
button.layer.shadowPath = [UIBezierPath bezierPathWithRect:button.layer.bounds].CGPath;
button.layer.shadowOpacity = 0.7;
button.layer.shadowColor = [UIColor blackColor].CGColor;
button.layer.shadowRadius = 10;
Am I missing anything?
Oh, and my button is a subclass of UIButton. I'm not sure if that makes a difference.. -Even with a shadowRadius of 0.0, I get a fully visible black square as my shadow
Upvotes: 4
Views: 806
Reputation: 38485
clipsToBounds
will allow any child views to be drawn outside the bounds of your button.
Looks like it doesn't apply to your layer though :(
You might just have to make your button a bit bigger (or your shadow smaller!)
Upvotes: 3