1

I would like to be able to have a UINavigationBar with a left-hand UIBarButtonItem, two right-hand UIBarButtonItems, and a title.

I have resorted to using a UIToolBar to simulate this, but the toolbar looks slightly different than the UINavigationBar, and it also won't bevel UIBarButtonSystemItems.

Is there a way to make a UINavigationBar with three UIBarButtonItems?

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
Andrew Johnson
  • 13,108
  • 13
  • 75
  • 116

3 Answers3

3

There's no way to do this using all native graphics. However, if you're willing to get your hands a little dirty in Acorn or Photoshop, you can create your buttons images there, and then add several buttons to a UIView, encase that in a UIBarBUttonItem, and set it to be the leftBarButtonItem.

This question tackles the item as well: How to add 2 buttons into the UINavigationbar on the right side without IB?

Community
  • 1
  • 1
Ben Gottlieb
  • 85,404
  • 22
  • 176
  • 172
  • Ugh, that's what I thought the answer probably was :). If no one chimes in with anything better, I'll gie you the checkmark. – Andrew Johnson Jan 08 '10 at 21:30
1

Since iOS5 it's easily possible ( https://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationItem_Class/Reference/UINavigationItem.html#//apple_ref/occ/instm/UINavigationItem/setRightBarButtonItems:animated: ) :

setRightBarButtonItems:animated:

Sets the right bar button items, optionally animating the transition to the new items. - (void)setRightBarButtonItems:(NSArray *)items animated:(BOOL)animated

Discussion

If two navigation items have the same custom left or right bar button items, those bar button items remain stationary during the transition when the navigation item is pushed or popped.

Availability Available in iOS 5.0 and later. Declared In UINavigationBar.h

jptsetung
  • 9,064
  • 3
  • 43
  • 55
1

I posted code to add two buttons to the right of the navigationBar. You can set barStyle = -1 instead of subclassing UIToolbar.

ma11hew28
  • 121,420
  • 116
  • 450
  • 651