Reputation: 1011
I have one UIImageView with a UIButton partially overlapping it. I want the user to see the image and the button as one joined object. When I try to give them drop shadow using QuartzCore:
image.layer.shadowOffset = CGSizeMake(5,5); button.layer.shadowOffset = CGSizeMake(5,5);
The Button's shadow will partly drop on the image. I want the button shadow to only drop for the part that are outside the image. Something like the union of two rectangles. Help will be appreciated!
Thanks
Leo
Upvotes: 0
Views: 722
Reputation: 385590
Put the UIImageView
and the UIButton
into a parent view. Set the shadow on the parent view. Make sure the parent view is not opaque and has a transparent background color:
- (void)viewDidLoad {
[super viewDidLoad];
self.shadowView.backgroundColor = [UIColor clearColor];
self.shadowView.opaque = NO;
self.shadowView.layer.shadowOffset = CGSizeMake(5, 5);
self.shadowView.layer.shadowColor = [UIColor blackColor].CGColor;
self.shadowView.layer.shadowOpacity = 1.0;
}
Upvotes: 1