简体   繁体   English

是否可以在iPhone中屏蔽CALayer?

[英]Is it possible to mask CALayer in iPhone?

I'm trying to mask CALayer with a bitmap image. 我正在尝试用位图图像遮罩CALayer。 And I failed masking CALayer. 而且我无法屏蔽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 "CALayer in iPhone does not support mask property" . 苹果参考资料显示“ iPhone中的CALayer不支持遮罩属性” But there is a postings about this on SO . 但是在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. 我使用了没有Alpha通道的图像。 Unlike traditional masking techniques, CALayer uses mask image's alpha channel as mask data. 与传统的遮罩技术不同,CALayer使用遮罩图像的Alpha通道作为遮罩数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM