I know I can use the @2x
tag to automatically load images for Retina screens. What other tags are supported?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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✕320Image@2x.png
for Retina, 960✕640Image-568h@2x.png
for Retina, 1136✕640, only after patchingUIImage
Image~iPad.png
for older iPads, 1024✕768Image@2x~iPad.png
for Retina iPad, 2048✕1536
All this is showcased in iOS Image Loader sample project on GitHub.