2

I have a big problem that is causing all sorts of complications. I want to make native-resolution graphics for my iPhone 5 app using the 326ppi Retina Display quality graphics. However, all of my Views seem to be defaulting at 320px width! So the only option I've been able to find is to make my graphics much larger, and then use the 'redraw' graphics option to make the graphics look somewhat nice.

However, I would much rather just use pixel-for-pixel native resolution images. What can I do to get xcode to show my views with retina display resolutions? I am using the latest xcode and programming for iOS 6.1

Thanks!

4

1 回答 1

1

In UIKit views are measured in points:

(CGSize){width, height}

. . where width and height are measured in points. On an iPhone 3GS (normal display), this gives the following widths:

(CGSize){320, 480} //screen resolution is 320x480

On an iPhone 4:

(CGSize){320, 480} //screen resolution is 640x960

. . ie - exactly the same. To draw a pixel at position {1,1} on an iPhone 4, the point would be:

(CGPoint}{0.5, 0.5}

Since the resolution on a retina display is exactly double, it makes drawing very easy between devices. UIKit will work out what pixel to set, given the hardware, when you supply floating point numbers. (Similar to the way OpenGL works). . . . it gets a little more complicated when supported 3.5 vs 4 inch screens.

For image assets, just name the resources as follows:

  • myResource.png - regular
  • myResource@2x.png - retina display
  • myResource-568@2x.png - retina display, especially for 4 inch screen. (Eg backgrounds, etc).
于 2013-06-09T06:28:57.983 回答