iPhone 中可以屏蔽 CALayer 吗?

发布于 2024-08-30 11:37:49 字数 762 浏览 5 评论 0原文

我正在尝试用位图图像掩盖 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尹雨沫 2024-09-06 11:37:49

这是我的错,现在已经解决了。我使用了没有 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文