开发者

Is it possible to mask CALayer in iPhone?

开发者 https://www.devze.com 2022-12-28 12:50 出处:网络
I\'m trying to mask CALayer with a bitmap image. And I failed masking CALayer. My code is: // \'PreloadViewController layerWithImageNamed\' create a layer and set it\'s contents as specified UIImage.

I'm trying to mask CALayer with a bitmap image. And I failed masking CALayer. My code is:

// 'PreloadViewController layerWithImageNamed' create a layer and set it's contents as specified UIImage.
CALayer* title = [PreloadViewController layerWithImageNamed:@"pinkhug_txt.png"];
 [[[self view] layer] addSublayer:title];

 CALayer* title_mask = [PreloadViewController layerWithImageNamed:@"hug_mask.png"];
 [title setMask:title_mask];

The Apple reference says "C开发者_如何学PythonALayer in iPhone does not support mask property". But there is a postings about this on SO. Is it possible? Or what's wrong with my code?


It was my fault and resolved now. I used an image without alpha channel. Unlike traditional masking techniques, CALayer uses mask image's alpha channel as mask data.

0

精彩评论

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