1

我正在尝试用位图图像掩盖 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 参考资料说“iPhone 中的 CALayer 不支持掩码属性”。但是在 SO 上有一个关于这个的帖子。可能吗?或者我的代码有什么问题?

4

1 回答 1

0

这是我的错,现在解决了。我使用了没有 Alpha 通道的图像。与传统的遮罩技术不同,CALayer 使用遮罩图像的 alpha 通道作为遮罩数据。

于 2010-05-01T09:30:56.740 回答