开发者

How to deal with different resolutions when designing images for iPhone3G and iPhone4

开发者 https://www.devze.com 2023-03-24 04:03 出处:网络
iPhone 4 has 960-by-640 resolution while iPhone 3G only 480-by-320. Do I have to design 2 different res. versions on of each on screen image when bu开发者_如何学编程ilding app and targeting both devic

iPhone 4 has 960-by-640 resolution while iPhone 3G only 480-by-320. Do I have to design 2 different res. versions on of each on screen image when bu开发者_如何学编程ilding app and targeting both devices? I'm building simple game with UIKit, and currently, most of my app on screen items are designed with interface builder. If separate version for each item is required than how to implement that?


No, you don't have to do double the work.

Lay out all of your screens assuming 320x480.

Create your graphics (typically PNG files) assuming a 640x960 display. Then create copies of each of the files at 50% of the original size. Use Apple's naming convention (below) and you'll be good to go -- high res graphics on retina displays and lower res graphics on non-retina displays.

Name a typical image file:

"myImage@2x.png" // for the retina image
"myImage.png"    // for the non-retina image

If you load the graphic programmatically, use:

UIImage *theImage = [UIImage imageNamed:@"myImage"];

Or you can just specify "myImage" in Interface Builder - it will load the right one automatically.

0

精彩评论

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