Using @2x files for a NonRetina iPad when @2x~ipad images exist

I have 3 images, file.png, file@2x.png and file@2x~ipad.png. I want to use file@2x.png on Retina iPhone and nonRetina iPad.

I want to set the images in interface builder . The iPhone works fine, where I set file.png in the xib and it loads file@2x.png on Retina iPhone. But on nonRetina iPad, file@2x~ipad.png is loaded even though I specified file@2x.png.

Is there a way to set nonRetina iPad to default to the @2x version when a ~ipad version doesn't exist through interface builder/xibs? (I'm well aware of loading images with different extensions through code by writing custom loading code) Are there any settings or plists I can change?

I don't want to make duplicates of the same image just to be able to name them differently.

Thanks.


Use symbolic links to point myImage~iPad.png to myImage@2x.png . Source https://stackoverflow.com/a/10223119/313875

Summary of this answer (read - someone else's answer to another question, so please go up-vote them!):

Use ln -s myImage@2x.png myImage~ipad.png for each image. Or use a script:

#! /bin/sh

# Script to batch create symlinks that point ~ipad files to @2X files

# To run:
# Copy to the directory where the files are located
# Enter the following at the terminal prompt:
# bash create_ipad_image_links.txt

# For every @2x file we find in this directory we create a symlink

for file in *@2x.png
do
  echo "link: ${file//@2x/~ipad} to: $file" 
  ln -s $file ${file//@2x/~ipad}
done

One way of doing this without adding duplicate files is by naming the iPad version file@2x@2x.png . You can then set the iPad version using either [UIImage imageNamed:@"file@2x"]; or set the image to file@2x.png to have file@2x@2x.png used on retina iPad and file@2x.png on normal iPad. That way there is no duplication.


Try creating file~ipad.png . Non-retina iPads should look for that file first.

链接地址: http://www.djcxy.com/p/62908.html

上一篇: App Target中的iPad Splash Screen设置警告

下一篇: 当存在@ 2x〜ipad图像时,将@ 2x文件用于NonRetina iPad