iPhone 中可以屏蔽 CALayer 吗?
我正在尝试用位图图像掩盖 CALayer。 我无法屏蔽 CALayer。我的代码是:
// '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];
Apple参考说 "CALayer iPhone 中不支持 mask 属性”。 但是有关于此的帖子。 是否可以?或者我的代码有什么问题?
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 "CALayer 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我的错,现在已经解决了。我使用了没有 Alpha 通道的图像。与传统的遮罩技术不同,CALayer 使用遮罩图像的 Alpha 通道作为遮罩数据。
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.