加载本地化UIImage [英] Loading a Localized UIImage

查看:165
本文介绍了加载本地化UIImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的iOS应用程序中加载本地化的图片,但也必须考虑到他们可能需要 ... @ 2x 种。

解决方案

更正的回答



[UIImage imageNamed:@TestImage] 首先查看Resources,如果没有找到,它会查看lproj dir文件夹。

$ b
$ b

NSLocalizedString 应该做的伎俩。请参见本地化字符串资源

  UIImage * img = [UIImage imageNamed:NSLocalizedString(@TestImage,@)]; 


I need to load localized images in my iOS app, but also have to take into account that they might need to be the ...@2x kind. How can I do this?

解决方案

Corrected Answer

[UIImage imageNamed:@"TestImage"] looks first into Resources, if nothing found, it then looks in the lproj dir folders. So you only need to put the localized images into the right folder.

Old Answer

NSLocalizedString should do the trick. See Localizing String Resources.

UIImage *img = [UIImage imageNamed:NSLocalizedString(@"TestImage",@"")];

这篇关于加载本地化UIImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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