开发者

iphone - UIImageView class shadow

开发者 https://www.devze.com 2023-01-18 23:59 出处:网络
I have a UIImageView based class. At the start of this class, I have this. if ([super initWithFrame:frame] == nil) {

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消