【问题标题】:Is it possible to mask CALayer in iPhone?是否可以在 iPhone 中屏蔽 CALayer?
【发布时间】:2019-06-04 21:54:53
【问题描述】:

我正在尝试用位图图像掩盖 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 in iPhone does not support mask property"。 但是有a postings about this on SO。 可能吗?或者我的代码有什么问题?

【问题讨论】:

  • 我添加了“iphone”标签。谢谢。

标签: iphone calayer masking


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2011-01-17
    • 1970-01-01
    • 2017-10-31
    • 2012-07-28
    • 1970-01-01
    • 1970-01-01
    • 2017-05-13
    • 1970-01-01
    相关资源
    最近更新 更多