gpt4 book ai didi

iOS 在呈现为模板的图像上使用默认颜色

转载 作者:行者123 更新时间:2023-11-29 10:23:12 24 4
gpt4 key购买 nike

我在 Assets 目录中有一组图片,每张图片都有自己的颜色。当设备处于离线状态时,我需要将此图标全部显示为灰色。

问题是:当我在 Assets 目录中的图像上设置模板模式时,我无法使用默认颜色集中的图像。

我想避免生成双图标。

想法?

最佳答案

如果图像是纯色的,没有背景,您可以对其进行着色。

    UIImage *image = [UIImage imageNamed:@"name"];
if (online) {
imageView.image = image;
} else {
imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[imageView setTintColor:[UIColor grayColor]];
}

我在应用程序中使用它在图像有新内容时对图像进行着色。

关于iOS 在呈现为模板的图像上使用默认颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33778682/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com