tags:

views:

98

answers:

1

I am trying to create a toolbar programatically (rather than via IB) very similar to the toolbar featured in the iPhone app.

Currently I've been experimenting with the UIToolbar class, but I'm not sure how (and if?) you can make the toolbar buttons centrally aligned and large like that in the iPod app.

Additionally, regardless of size, the gradient/reflection artwork never correctly respects the size and is stuck as if the object is the default smaller size.

If this cannot be done with a standard UIToolbar, I guess I need to create my own view. In this case, can the reflection/gradient be created programmatically or will it require some clever alpha tranparency Photoshopped artwork?

A: 

The best thing you can do is:

  • create MyToolbar.h and MyToolbar.m : MyToolbar can be inherited from UIToobar
  • create an empty xib named MyToolbar.xib
  • In Interface Builder, add a new UIToolBar with "IB->Tools->Library"
  • With "IB->Tools->Inspector", change the class identity to "MyToolbar"

Now, you can customize your toolbar with IB or with xCode as you want.

Max Brice
Thanks but I'm not doing this via IB. I've edited my question to make this clearer.
andybee