Can't set cornerRadius AND shadow on layer that has an image view stretched to its bounds?

前端 未结 5 718
醉话见心
醉话见心 2020-12-31 03:00

This is stumping me. I have a UIView (call it \"parent\"). The bottommost subview of that view is a UIImageView (call it \"child\"), whose frame occupies the entirety of the

5条回答
  •  温柔的废话
    2020-12-31 03:46

    You will need two nested views, the inner one setting rounded corners and clipping to bound, and the outer view having the shadow (and therefore not clipping). In your case inner and outer view will probably be "child" and "parent", but I guess you didn't set the right clipping values for these views?

    See the answer in Why masksToBounds = YES prevents CALayer shadow?.

提交回复
热议问题