开发者

iPhone Design - Managing Multiple Versions

I notice that the screen resolution for the iPhone 3+ is 240x480 and the iPhone 4 is 640x960 ...

Does this mean that you'd want to have 2 sets of graphics that utilize the extra resolu开发者_运维问答tion? My first thought on that would be that the higher the resolution, the smaller the graphics would appear.


You do need two sets of graphics. The older iPhones are actually 320x480. In general you can provide only a low resolution graphic if you'd like, and it will be automatically upscaled, but going only one high resolution graphic doesn't work automatically. The handling of the second graphic is done automatically, based on filename, so you would have one file named mygraphic.png, and a second named mygraphic@2x.png. Since the new screen is exactly double the resolution of the old screen, you don't need to do anything special to get it working beyond having the second file in place.


As Sam outlined, UIImage will automatically load the appropriately scaled file based on presence of @2x in the filename. However, you can also access the screen scale directly by calling [[UIScreen mainScreen] scale] -- this will return 2 on retina devices and 1 on older 320x480 devices. You can use the scale value to pull down higher resolution images from the web, when drawing or modifying images with Core Graphics, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜