Making High-Resolution iPhone 4 Apps
Today, after making a little drawing program in OpenGL (yes, that’s how bored I was), I decided to look into making my applications for iPhone 4 take advantage of the retina display. I was surprised to find no option in Xcode 4 (developer seed) to make an iPhone 4 specific application. Instead, there is only an option to make your app for iPad, or for iPhone.
I figured, “maybe I can just set the window size to be bigger in interface builder.” Before I even did that, I decided to do a few tests. I have realized that some of the apps I have on my iPhone 4 are not made specifically for the retina display, but still have a lot of graphics that look full-resolution on it. To run a test, I made an app with the iPhone 3GS and earlier screen size (320×480) and put an assortment of UI controls on it using interface builder.
When I ran the application on the iPhone 4 simulator, I was pleased to find that all of the components were full 640×960 resolution. I then ran another few tests to find that iOS 4 on the iPhone 4 is quite good at determining the best way to make things sharp and perfect on the retina display.
Another cool thing that I noticed is that a lot of my apps use large images, and simply scale them down to fit a rectangle on the iPhone’s display. Although their coordinates are the same, when I use UIKit to draw them, they are automatically drawn at 4x the resolution (if possible). This means that apple most likely draws their UI components at full resolution, and translates their bounds and origins when my code asks for them.
I found that the following methods of drawing graphics were automatically transformed for the iPhone 4 by iOS but still functioned perfectly on both the iPhone 4 and the iPhone 3G:
- Core Graphics calls (gradients, arcs, images, etc)
- UI components (UIImageView, UIButton, it’s all there)
- Fonts (drawing text with Quartz or UIKit)
- CoreAnimation rotations and scales
- UIKit Keyboard (goes without saying)
I will continue to explore the ways to take advantage of the iPhone 4′s retina display, but for now I am simply amazed at the wonderful job apple has done making the retina display effective for every app.