如何在通用应用程序中同时支持iPad和iPhone视网膜图形

时间:2020-12-02 15:49:46

Apple presented new iPad that support retina graphics.

苹果推出了支持视网膜图形的新iPad。

I saw this link retina graphic in apple apps. As you can see apple just use "@2x" suffix for retina iPad display.

我在苹果应用程序中看到了这个链接视网膜图形。正如你所看到的,苹果只在retina iPad显示屏上使用了“@2x”后缀。

I have an universal app. So how to support retina in new iPad and iPhone? Will iPad retina use suffix "@2x" similar to iPad?

我有一个通用的应用程序,那么如何在新的iPad和iPhone上支持视网膜呢?iPad视网膜会像iPad一样使用“@2x”的后缀吗?

2 个解决方案

#1


138  

I just created a test app and tested.

我刚刚创建了一个测试应用程序并进行了测试。

So for devices without retina:
ImageName.png - For iPhone/iPod
ImageName~ipad.png -- For iPad

对于没有视网膜的设备:ImageName。png -用于iPhone/iPod ImageName~ipad。png——iPad

For devices with retina display:
ImageName@2x.png - For iPhone/iPod
ImageName@2x~ipad.png -- For iPad

视网膜显示设备:ImageName@2x。适用于iPhone/iPod ImageName@2x~ipad。png——iPad

And you can still use @2x if your iPhone high resolution image and iPad high resolution image have the same size.
To load the image just use [UIImage imageNamed:@"ImageName.png"];
I just tested it on iOS simulator for iOS 5.1, 5.0 and 4.3.
By the way why you should use @2x and nothing more.

如果你的iPhone高分辨率图像和iPad高分辨率图像的尺寸相同,你仍然可以使用@2x。要加载图像,只需使用[UIImage imageNamed:@"ImageName.png"];我刚刚在iOS模拟器上测试了iOS 5.1、5.0和4.3。顺便说一下,为什么你应该使用@2x,而不是更多。

The main thing because you shouldn't use the same graphics on iPhone and iPad, because iPhone and iPad has different size. And if you will use the same size the graphics will already done for you iPad retina display (if you previously use iPhone retina display). If you will images with different size, so you will use different image names for iPhone and iPad. So in this side you need just add @2x suffix. That's why you should use just @2x suffix. - these are my thoughts.

主要是因为你不应该在iPhone和iPad上使用相同的图形,因为iPhone和iPad的尺寸不同。如果你使用同样大小的图形已经为你做了iPad视网膜显示器(如果你以前使用iPhone视网膜显示器)。如果你要用不同尺寸的图片,你会用不同的iPhone和iPad的图片名称。在这边你只需要添加@2x后缀。这就是为什么你应该使用@2x后缀。-这是我的想法。

#2


6  

I found that the iPad mini/non retina iPad hardware, not simulator, would fall back on ImageName.png, not ImageName~ipad.png as you would expect from rowwingman's answer.

我发现iPad mini/non - retina iPad硬件,而不是模拟器,会回到ImageName上。png,不是ImageName ~ ipad。正如你所期待的那样,罗温曼的回答是这样的。

Looking at the docs, referenced in another * question by Nate, it seems as though appending the device to iphone images is the correct way to do it.

看看内特提出的另一个*问题中提到的文档,似乎把设备附加到iphone图像上是正确的做法。

MyImage.png - Default version of an image resource.

模板。png -图像资源的默认版本。

MyImage@2x.png - High-resolution version of an image resource for devices with Retina displays.

MyImage@2x。png -高清版本的图像资源的设备与视网膜显示器。

MyImage~iphone.png - Version of an image for iPhone and iPod touch.

模板~ iphone。png -版本的图像为iPhone和iPod touch。

MyImage@2x~iphone.png - High-resolution version of an image for iPhone and iPod touch devices with Retina displays.

MyImage@2x ~ iphone。png -高清版本的图像为iPhone和iPod touch设备与视网膜显示器。

Image, Sound, and Video Resources

图像、声音和视频资源

#1


138  

I just created a test app and tested.

我刚刚创建了一个测试应用程序并进行了测试。

So for devices without retina:
ImageName.png - For iPhone/iPod
ImageName~ipad.png -- For iPad

对于没有视网膜的设备:ImageName。png -用于iPhone/iPod ImageName~ipad。png——iPad

For devices with retina display:
ImageName@2x.png - For iPhone/iPod
ImageName@2x~ipad.png -- For iPad

视网膜显示设备:ImageName@2x。适用于iPhone/iPod ImageName@2x~ipad。png——iPad

And you can still use @2x if your iPhone high resolution image and iPad high resolution image have the same size.
To load the image just use [UIImage imageNamed:@"ImageName.png"];
I just tested it on iOS simulator for iOS 5.1, 5.0 and 4.3.
By the way why you should use @2x and nothing more.

如果你的iPhone高分辨率图像和iPad高分辨率图像的尺寸相同,你仍然可以使用@2x。要加载图像,只需使用[UIImage imageNamed:@"ImageName.png"];我刚刚在iOS模拟器上测试了iOS 5.1、5.0和4.3。顺便说一下,为什么你应该使用@2x,而不是更多。

The main thing because you shouldn't use the same graphics on iPhone and iPad, because iPhone and iPad has different size. And if you will use the same size the graphics will already done for you iPad retina display (if you previously use iPhone retina display). If you will images with different size, so you will use different image names for iPhone and iPad. So in this side you need just add @2x suffix. That's why you should use just @2x suffix. - these are my thoughts.

主要是因为你不应该在iPhone和iPad上使用相同的图形,因为iPhone和iPad的尺寸不同。如果你使用同样大小的图形已经为你做了iPad视网膜显示器(如果你以前使用iPhone视网膜显示器)。如果你要用不同尺寸的图片,你会用不同的iPhone和iPad的图片名称。在这边你只需要添加@2x后缀。这就是为什么你应该使用@2x后缀。-这是我的想法。

#2


6  

I found that the iPad mini/non retina iPad hardware, not simulator, would fall back on ImageName.png, not ImageName~ipad.png as you would expect from rowwingman's answer.

我发现iPad mini/non - retina iPad硬件,而不是模拟器,会回到ImageName上。png,不是ImageName ~ ipad。正如你所期待的那样,罗温曼的回答是这样的。

Looking at the docs, referenced in another * question by Nate, it seems as though appending the device to iphone images is the correct way to do it.

看看内特提出的另一个*问题中提到的文档,似乎把设备附加到iphone图像上是正确的做法。

MyImage.png - Default version of an image resource.

模板。png -图像资源的默认版本。

MyImage@2x.png - High-resolution version of an image resource for devices with Retina displays.

MyImage@2x。png -高清版本的图像资源的设备与视网膜显示器。

MyImage~iphone.png - Version of an image for iPhone and iPod touch.

模板~ iphone。png -版本的图像为iPhone和iPod touch。

MyImage@2x~iphone.png - High-resolution version of an image for iPhone and iPod touch devices with Retina displays.

MyImage@2x ~ iphone。png -高清版本的图像为iPhone和iPod touch设备与视网膜显示器。

Image, Sound, and Video Resources

图像、声音和视频资源