The buttons in the iPhone SDK suck. There, I said it.
Almost everything on the iPhone round, glossy and “3Dish”.
Except the standard RoundRect buttons included in UIKit.
Of course we can go off and use one of many drawing apps to crank out some nice glossy buttons, but there a few problems with this approach.
First, you have to be at least competent in using some advanced drawing tool.
Second, any buttons you create are static and must be shipped as a resource in your app. It is acceptable to want to generate multiple colors on the fly.
To solve our dilemma, we can use the work of two other people.
Matt Gallagher posted a great article on generating gloss gradients a while back.
It’s quite informative in explaining and implementing the effect. You can run a OS X app and play around with the setting.
The code didn’t quite work on the iPhone because of the absence of NSColor.
So we have two problems. First, we need to adapt the code to the iPhone. Second, we need to add this code to UIButton as a category.
Good news everyone! It’s already been done.
More than that, you can follow a 5 step tutorial taking you through the process of building the code and some explanation behind it.
The first post of the series can be found here.
I would credit the author, but I think he (or she) has gone through great pains to omit his (or her) name from the blog. (Or maybe I’m just too dense).
Update: Michael Heyeck wrote in to claim his awesome work and updated his “About” page to be a little more forthcoming.
Anyways, try it out. It works good for making glossy buttons pretty quickly and it is tweak-able.