In a magazin I read about some nice extensions for the UIView class. You will be able to add a border with corner radian or a drop shadow to any UIView.
@implementation UIView (Extentions)
-(void) enableRoundRectsWithValue:(float)value
{
self.layer.masksToBounds = true;
self.layer.cornerRadius = value;
}
-(void) enableShadow
{
self.layer.masksToBounds = false;
self.layer.shadowOffset = CGSizeMake(0,2);
self.layer.shadowOpacity = 0.5;
}
@end
While these methods work fine for themselves they don't play nice together. I can't have a corner radius and a shadow. At least not like you expect them to be. I guess because masksToBounds is set to true in one method and false in the other.
How can I get a UIView with a corner radius and also a shadow (with the same corner radius)?
It's kind of old but more people with the same problem can get here looking for a solution.
I guess this post can help. It explains a little about CALayer
and about mixing effects, including corner radius and shadows.
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