ios 给uiview创作遮罩

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];

posted @ 2014-05-16 00:02  饮识止渴  阅读(916)  评论(0编辑  收藏  举报