SamirChen SamirChen - 9 months ago 337
iOS Question

How to localize the images in Images.xcassets?

We can localize an image in the

File Inspector
like this:

enter image description here

Then we can get this:

enter image description here

But now, I use Images.xcassets to manage my images in my iOS project, how should I localize these images in Images.xcassets?

cc. cc.

While there's (apparently) not currently a way to explicitly localize the xcassets file directly, you could localize the name of the asset to pull using your Localizable.strings file. For instance, say you have a graphic logo treatment for the main menu of a game that needs to be localized. You could put the localized logo treatments in the assets file with different names, add the names to your Localizable.strings file, and then fetch the appropriate image with code like this:

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