views:

512

answers:

1

Hi, I've created a UIBarButtonItem and then set self.navigationItem.rightBarButtonItem to the item.

However, setting the width property of the barButtonItem doesn't seem to have any effect on the width of the button (I'm trying to reduce the width of the barButton)

If I use a custom view for the UIBarButtonItem, I'm able to set the width of the view (and that in turn sets the width of the barButton)

However, I want to get the look and feel of the standard UIBarButtonItem.

Does anyone know how to reduce the width of the UIBarButtonItem without using a custom view ? (alternately, does anyone know how to create a UIView or UIButton that looks like a UIBarButtonItem)

A: 

Looks like Apple really don't want it (Human Interface Guidelines). However there is a somewhat static solution if you use your own view for it:

Just use images instead... use grab to copy the images from IB at the widths you want. Then they'll look exactly like the UIBarButtons

Apple shows you how to map two different images (and in this example functions as well) to the same button depending on the state... check out the "Add Music" sample code: http://developer.apple.com/iphone/library/samplecode/AddMusic/index.html

This is from TechGuru @ http://discussions.apple.com/thread.jspa?messageID=9822548

Gerd