Can I mask CALayer on iPhone?

I am trying to mask CALayer with a bitmap. And I was unable to mask CALayer. My code is:

// 'PreloadViewController layerWithImageNamed' create a layer and set it 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];

Apple's link reads: "CALayer on iPhone does not support mask properties . " But there are reports of this on SO . Is it possible? Or what's wrong with my code?

+1
source share
1 answer

That was my mistake and now resolved. I used an image without an alpha channel. Unlike traditional masking methods, CALayer uses the alpha channel of the mask image as mask data.

0
source

All Articles