从xcassets加载应用程序图标 [英] Load app icon from xcassets

查看:91
本文介绍了从xcassets加载应用程序图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用中显示应用图标。该图标位于默认资产目录中( Images.xcassets )。

I'd like to display the app icon inside my app. The icon is in the default assets catalog (Images.xcassets).

如何加载它?我尝试了以下内容,他们都返回 nil

How do you load it? I tried the following and they all return nil:

image = [UIImage imageNamed:@"AppIcon"];
image = [UIImage imageNamed:@"icon"];
image = [UIImage imageNamed:@"icon-76"];
image = [UIImage imageNamed:@"icon-60"];

资产目录中的其他图像按预期工作。

Other images in the assets catalog work as expected.

推荐答案

通过检查捆绑包,我发现图标图像被重命名为:

By inspecting the bundle I found that the icon images were renamed as:

AppIcon76x76~ipad.png
AppIcon76x76@2x~ipad.png
AppIcon60x60@2x.png

等等。

因此,使用 [UIImage imageNamed:@AppIcon76x76] 或类似的作品。

Thus, using [UIImage imageNamed:@"AppIcon76x76"] or similar works.

这是在某处记录的吗?

这篇关于从xcassets加载应用程序图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆