5
votes

I read from http://www.apple.com/iphone/specs.html that IPhone4's screen is 960-by-640-pixel resolution at 326 ppi.

But in Xcode's IPhone4.3 simulator, when I manipulate the display objects, print the [UIScreen mainScreen].applicationFrame, it is 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?

Or Which kind of images should I use ? The size of images can affect the details a lot.

3

3 Answers

4
votes

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.

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 [email protected] (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.

3
votes

You should create two images for the same background.

1st Image = background.png dimensions = 320x480
2nd Image = [email protected] dimensions = 640x960

The iphone will automatically use the "@2x" image with the retina display.

Tip: when creating this image, create the image as 640x960 and then just resize it by half when done.

Note: this works the same for ALL images. Button, images, backgrounds etc..

0
votes

One. (not both)

It is best practice to do one because your application bundle smaller on download and easier to manage in 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. iOS puts the image in place according to the point grid regardless of image resolution. 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). http://achim.us/eli/iOS_Graph_Paper.pdf