本文介绍了是否可以在iPhone中屏蔽CALayer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试用位图图像遮盖CALayer。
而且我没有掩盖CALayer。我的代码是:
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];
Apple参考说。
,但是有。
有可能吗?还是我的代码有什么问题?
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?
推荐答案
这是我的错,现在已解决。我使用了没有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.
这篇关于是否可以在iPhone中屏蔽CALayer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!