mask一定是PNG格式的图像,去掉背景 .jpg格式图片没有alpha
values
遮罩是通过图片透明度的信息实现与颜色无关
UIImage*_maskingImage
=[UIImage imageNamed:@"mask"];
CALayer*_maskingLayer =[CALayer
layer];
_maskingLayer.frame =
theView.bounds;
[_maskingLayer setContents:(id)[_maskingImage
CGImage]];
[theView.layer setMask:_maskingLayer];
ios 给uiview创作遮罩,布布扣,bubuko.com
原文:http://www.cnblogs.com/lzl-sml/p/3731254.html