views:

62

answers:

2

I've run into the issue of using a UIBarButtonItem with a custom color. Everything out on the 'net seems to indicate that the only way around this lack of official API support revolves around the use of images. This is all fine and dandy when developing for pre-iOS 4 devices, except when using the new iPhone 4. Creating an image for iPad and pre-iOS 4 devices is straightforward enough, but the images developed for those devices look absolutely horrid on iPhone 4. I suspect that this problem will be exacerbated further with the introduction of next generation devices.

Consider the example below. Notice how the default colored button is nice and smooth, but the iPhone 3GS image looks terrible. It does not seem very scalable (pun intended) to have to include multiple images for different resolution devices.

alt text

In the absence of an official API for changing the color of a UIBarButtonItem, what strategies are out there for creating images that scale well against differing resolution devices? This problem is hardly unique to UIBarButtonItems, how is the community adapting to other UI elements that are bitmapped? Is there a better solution for this particular case than using an image (such as using Quartz to draw it)?

If at all possible, please offer concrete code examples.

+1  A: 

If you look at the source for Three20 you can see how they draw custom buttons and shapes that will scale well, regardless of resolution.

Jasarien
Couldn't edit your post (curse you, 2000 rep!), but I believe this would be a helpful link to include in your post: http://three20.info/style/overview
Wayne Hartman
+3  A: 

You can list any image as [email protected] along with Image.png and the system will select the appropriate image at runtime.

Jesse Tayler
Didnt know that, awesome
code_burgar