iphone 5视网膜显示器的图像 [英] Images for iphone 5 retina display

查看:120
本文介绍了iphone 5视网膜显示器的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iPhone 5发布,具有新的屏幕尺寸和分辨率。

iPhone 5 released, with new screen size and resolution.

当我们使用iPhone 4(视网膜)图像时,我们只是将@ 2x添加到图像名称。
任何人都可以告诉我,是否有可能为新的iPhone屏幕添加不同的图像(背景,按钮等)?

When we used images for iPhone 4 (retina), we just added "@2x" to image name. Can anybody tell me, is it possible to add different images (backgrounds, buttons, etc), for new iPhone screen?

第二个问题:可以我在我的应用程序中有单独的XIB文件:对于旧的iPhone,iPhone新的(如iPhone和iPad)?

And the second question: can I have in my app separate XIB files: for iPhone old, iPhone new (like for iPhone and iPad)?

谢谢!

推荐答案

以下是我的博客中有关此主题的内容:

Here's an except from my blog about this subject:

[UIImage imageNamed:]自动加载@ 2x在视网膜设备上运行时的图像版本。不幸的是,imageNamed:在iPhone 5上运行时不会自动加载-568h @ 2x版本的图像。

[UIImage imageNamed:] automatically loads @2x versions of images when running on a retina device. Unfortunately, imageNamed: will NOT automatically load -568h@2x versions of images when running on an iPhone 5.

有时这无关紧要,例如图标和非iPhone 4上的全屏图形可能是相同的。 5.但是,如果您有全屏幕背景图像或工具栏等的全宽/高度背景图像,您将遇到问题。您的480高图像很可能会被拉伸(结果可能看起来很可怕)。

Sometimes this doesn't matter, for example icons and non-full screen graphics are probably the same on iPhone 4 & 5. However, if you have full-screen background images, or full-width / height background images for toolbars etc you will have problems. Your 480-high images will most likely get stretched (and will probably look horrid as a result).

您可以手动检查屏幕尺寸并加载正确的图像,如下所示:

You can manually check the screen size and load the right image like this:

UIImage* myImage;
CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height;
if ([UIScreen mainScreen].scale == 2.f && screenHeight == 568.0f) {
   myImage = [UIImage imageNamed:@"myImage-568h.png"];
} else {
   myImage = [UIImage imageNamed:@"myImage.png"];
}

有一种方法可以改变UIImage imageNamed以便 >自动加载正确的图像。请参阅以下链接了解详情。

There's a way of altering UIImage imageNamed so it does automatically load the right image. See link below for details.

更多内容: http://pervasivecode.blogspot.co.uk/2012/09/making-apps-work-on-iphone-5-screen-size.html

编辑:@Sound Blaster& @GrizzlyNetch 是正确的,在代码中你应该使用imageNamed:@myImage-568h.png]但是实际文件名应该是myImage-568h@2x.png。如果你不这样做,那么比例是不正确的,就像他们说的那样。

@Sound Blaster & @GrizzlyNetch are right, in code you should use imageNamed:@"myImage-568h.png"] but the actual file name should be myImage-568h@2x.png. If you don't do this, then the scale is incorrect, just like they said.

这篇关于iphone 5视网膜显示器的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆