且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-10-20 13:21:58

我刚刚创建了一个测试应用并进行了测试.

I just created a test app and tested.

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

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

对于配备 Retina 显示屏的设备:
ImageName@2x.png - 适用于 iPhone/iPod
ImageName@2x~ipad.png -- 对于 iPad

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

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

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 上使用相同的图形,因为 iPhone 和 iPad 的尺寸不同.如果您将使用相同尺寸的图形,则 iPad 视网膜显示已经完成(如果您以前使用 iPhone 视网膜显示).如果您要使用不同尺寸的图像,那么您将为 iPhone 和 iPad 使用不同的图像名称.所以在这一边你只需要添加@2x 后缀.这就是为什么你应该只使用@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.