iphone - UIImageView class shadow
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
I figured out based on the commend of vodkhang.
The problem is
self.layer.masksToBounds = YES;
I suppose the mask clips the shadow.
Just add a CALayer under the image with a shadow. The image with a masksToBounds of YES and the shadow layer NO.
精彩评论