简体   繁体   English

关于iPhone4屏幕分辨率

[英]About IPhone4 screen resolution

I read from http://www.apple.com/iphone/specs.html that IPhone4's screen is 960-by-640-pixel resolution at 326 ppi.我从http://www.apple.com/iphone/specs.html读到 iPhone4 的屏幕分辨率为 960 x 640 像素,分辨率为 326 ppi。

But in Xcode's IPhone4.3 simulator, when I manipulate the display objects, print the [UIScreen mainScreen].applicationFrame, it is 320*480.但是在Xcode的IPhone4.3模拟器中,当我操作显示对象时,打印出[UIScreen mainScreen].applicationFrame,它是320*480。

So if I wanna use a picture as the main screen's background of my app, which size I should use?所以如果我想用一张图片作为我的应用程序的主屏幕背景,我应该使用哪种尺寸? 640*960 or 320*480? 640*960 还是 320*480?

Or Which kind of images should I use?或者我应该使用哪种图像? The size of images can affect the details a lot.图像的大小对细节的影响很大。

You can use both.您可以同时使用两者。

If you want to develop apps to Retina Display (iPhone 4), then you should use image with double resolution (640x960), then, when you create your UIImageView, you divide the size by 2.如果您想为 Retina Display (iPhone 4) 开发应用程序,则应使用双分辨率 (640x960) 的图像,然后在创建 UIImageView 时,将大小除以 2。

CGRect rect = imageView.frame;
rect.size.width /= 2;
rect.size.height /= 2; 
imageView.frame = rect;

Also, you have the option to have a image with @2x on its name, for example myimage@2x.png (640x960).此外,您还可以选择名称中带有 @2x 的图像,例如myimage@2x.png (640x960)。 In this case, you don't need to divide the size.在这种情况下,您不需要划分大小。 Using this way:使用这种方式:

UIImage * img = [UIImage imageNamed:@"myimage.png"];

Your img var has already divided the size, and if you deploy to iPhone4 it has Retina Display resolution.您的 img var 已经划分了大小,如果您部署到 iPhone4,它具有 Retina Display 分辨率。

You should create two images for the same background.您应该为相同的背景创建两个图像。

1st Image = background.png dimensions = 320x480第一张图片 = background.png 尺寸 = 320x480
2nd Image = background@2x.png dimensions = 640x960第二张图片 = background@2x.png 尺寸 = 640x960

The iphone will automatically use the "@2x" image with the retina display. iphone 将自动使用“@2x”图像和视网膜显示。

Tip: when creating this image, create the image as 640x960 and then just resize it by half when done.提示:创建此图像时,将图像创建为 640x960,然后在完成后将其大小调整一半。

Note: this works the same for ALL images.注意:这对所有图像都一样。 Button, images, backgrounds etc..按钮、图像、背景等。

One.一。 (not both) (不是都)

It is best practice to do one because your application bundle smaller on download and easier to manage in XCode.最佳做法这样做,因为您的应用程序包在下载时更小,并且在 XCode 中更易于管理。 Always create images sized for retina pixel display.始终创建尺寸适合视网膜像素显示的图像。

Why?为什么?

Both retina and standard pixel displays use the same point system even with different screen resolutions.即使屏幕分辨率不同,视网膜和标准像素显示器也使用相同的点系统。 For example, this is why on iPhone - when asking the window.frame.size.. - returns 320X480, even when the iPhone has a retina display.例如,这就是为什么在 iPhone 上 - 当询问 window.frame.size.. 时 - 返回 320X480,即使 iPhone 有视网膜显示器。 iOS puts the image in place according to the point grid regardless of image resolution. iOS 无论图像分辨率如何,都根据点网格将图像放置到位。 That image resolution might as well be able to handle either standard or retina displays.该图像分辨率也可能能够处理标准或视网膜显示器。

Therefore, always create images sized for retina pixel display.因此,请始终创建尺寸适合视网膜像素显示的图像。

Feel free to print out custom made graphing paper (with dimensions and commonly used components included) to help sketch out your views (not everything should be done digitally:D).随意打印出定制的绘图纸(包括尺寸和常用组件),以帮助勾勒出您的视图(并非所有事情都应该以数字方式完成:D)。 http://achim.us/eli/iOS_Graph_Paper.pdf http://achim.us/eli/iOS_Graph_Paper.pdf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM