如何使用特定语言的本地化UIImage?
我的应用程序中有设置,并且希望用户能够切换应用程序的语言。语言可能与设备设置不同。
对于 NSStrings,我找到了一个解决方案,但是如何使用 UIImages 做到这一点?
我已经本地化了所有图像,但现在根据设备语言选择它们。我需要做什么才能使其正常工作?我现在唯一的选择是将名称放入 Localized.strings 中并从那里加载它们。
有更好的方法吗?
谢谢 ;-)
I have settings in my App and want to give the user the possibility to switch the language of the app. The language can be different to the device setting.
For the NSStrings I found a solution but how can I do it with UIImages?
I've localized all my images but now they are chosen depending on the device language. What do I have to do to get this working? My only option that I have right now is to put the names in the Localizable.strings and load them from there.
Is there a better way to do this?
Thx ;-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的东西:
- [NSBundle URLForResource:withExtension:subdirectory:localization:]
- [NSBundle pathForResource:ofType:inDirectory:forLocalization:]
应该这样做。
然后只需使用类似:
-[UIImage initWithContentsOfFile:]
-[UIImage initWithData:]
来创建
UIImage
。Something like:
- [NSBundle URLForResource:withExtension:subdirectory:localization:]
- [NSBundle pathForResource:ofType:inDirectory:forLocalization:]
should do it.
Then just use something like:
-[UIImage initWithContentsOfFile:]
-[UIImage initWithData:]
for creating a
UIImage
.