Apart from @2x, what other tags are supported by U

2019-09-07 07:09发布

I know I can use the @2x tag to automatically load images for Retina screens. What other tags are supported?

标签: ios uiimage
1条回答
淡お忘
2楼-- · 2019-09-07 07:33

There are currently three supported tags:

  • @2x for Retina screens.
  • ~iPad for iPad, has to be the last tag before the extension.
  • ~iPhone for iPhone and iPod Touch, again, has to be the last.

For the splash screen there’s also the Default-568h@2x version for iPhone 5. This suggests that you can use -568h to automatically load images for iPhone 5, but that’s unfortunately not the case (rdar://12516489). You can patch the UIImage class to add the support yourself.

In the end there are five possible image variants:

  • Image.png for older devices, 480✕320
  • Image@2x.png for Retina, 960✕640
  • Image-568h@2x.png for Retina, 1136✕640, only after patching UIImage
  • Image~iPad.png for older iPads, 1024✕768
  • Image@2x~iPad.png for Retina iPad, 2048✕1536

All this is showcased in iOS Image Loader sample project on GitHub.

查看更多
登录 后发表回答