Reputation: 1006
I have achieved a view that looks like this —
But I want the bottom of the view to look like this —
Adding a shadow is not helping because as soon as I do maskToBounds = YES
, I get what I have in the first picture. This is the code I have so far
[self.contentView.layer setCornerRadius:3.0f];
UIColor* color = CardBorderColor; // this is a macro that defines the color
[self.contentView.layer setBorderColor:color.CGColor];
[self.contentView.layer setBorderWidth:1.0f];
[self.contentView.layer setShadowColor:color.CGColor];
[self.contentView.layer setShadowOpacity:1.0];
[self.contentView.layer setShadowRadius:3.0];
[self.contentView.layer setShadowOffset:CGSizeMake(1.0, 1.0)];
self.contentView.layer.masksToBounds = YES;
Upvotes: 0
Views: 258
Reputation: 37290
Unfortunately, yes, using masksToBounds
will mask out your shadow. If you need to set maskToBounds = YES
for another element in that view, then put the view that requires masksToBounds on top of another UIView
and adding the shadow to that bottom view.
Upvotes: 3
Reputation: 1214
This tutorial link may help you..
http://nscookbook.com/2013/01/ios-programming-recipe-10-adding-a-shadow-to-uiview/
How do I draw a shadow under a UIView?
Upvotes: 0