Adding a mask with CALayers

后端 未结 2 507
清酒与你
清酒与你 2021-02-07 21:51

I seem to be having difficulties adding a mask via CALayers. I\'m simply trying to mask a UIImageView. Here\'s my code:

 CALayer *maskLayer = [CALayer layer];
 U         


        
2条回答
  •  太阳男子
    2021-02-07 22:12

    Try

    maskLayer.contents = (id)mask.CGImage;
    

    Yes, the cast sucks, but it's necessary.


    I think you'll also need to say

    maskLayer.bounds = (CGRect){CGPointZero, mask.size};
    

提交回复
热议问题