Featured iPhone Development Resources

Create Great Looking UIButtons Quick And Easy

If you’ve used interface builder then you’ve probably noticed that you can change the colors and the actual image used for a UIView or UIButton background.  The problem with doing this is that things end looking just a bit off.  Either the corners are squared, things are off center or the other view elements just end up not looking right and you wind up either giving up or changing everything.  I found this excellent tutorial from Matt Long, co-writer of the Core Animation book on creating custom buttons and views easily that just look great.

By changing the layer attributes of the button is it possible to keep the rounded button look while changing the color, and using CAGradientLayer it is possible to add some great looking gradients.  You can see Matt’s tutorial for doing this here along with a nice sample application: Fun With UIButtons and Core Animation Layers

A useful resource for customizing the gradient effects can be found here:
The CAGradientLayer Class Reference

If you’d like to make gradient UITableView cells check out:
How To Make Ultra-Slick Gradient UITableView Cells

Hope this helps.  I like it alot better than changing the background images myself.  Please post any comments below.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.