Reputation: 35933
I have a UIImageView based class.
At the start of this class, I have this.
if ([super initWithFrame:frame] == nil) {
return nil;
}
self.layer.cornerRadius = 6.0;
self.layer.masksToBounds = YES;
self.layer.shadowOffset = CGSizeMake(3,3);
self.layer.shadowOpacity = 0.7f;
self.layer.shadowRadius = 5.0;
// bla bla
Despite the shadow being declared there, all objects created with this class using initWithFrame, don't show any shadow.
am I missing something?
thanks
Upvotes: 0
Views: 2097
Reputation: 4634
Just add a CALayer under the image with a shadow. The image with a masksToBounds of YES and the shadow layer NO.
Upvotes: 0
Reputation: 35933
I figured out based on the commend of vodkhang.
The problem is
self.layer.masksToBounds = YES;
I suppose the mask clips the shadow.
Upvotes: 1