5

I am able to unhide the navigation controller bottom bar by using the following code

[self.navigationController setToolbarHidden:NO];

But now I want to change the color of the bottom bar and also add buttons to that bottom bar. Can any one please help me how to do that is there any delegate methods for that?

Luiggi Mendoza
  • 85,076
  • 16
  • 154
  • 332
user564963
  • 2,284
  • 5
  • 24
  • 33

1 Answers1

14

In the viewDidLoad method of each view controller that you are displaying within the navigation controller, add code such as the following:

//set up the toolbar
[self.navigationController setToolbarHidden:NO];
[self.navigationController.toolbar setBarStyle:UIBarStyleBlackOpaque];  //for example

//set the toolbar buttons
 [self setToolbarItems:[NSArray arrayWithObjects:button1, button2, nil]];  

In this case, button1 and button2 are IBOutlet properties of the view controller, with the actual buttons defined as UIBarButtonItem within IB (but not part of the view hierarchy within IB).

Alternatively you can use code to create the buttons - like this:

UIBarButtonItem* button1 = [[[UIBarButtonItem alloc] initWithTitle:@"Button Text" style:UIBarButtonItemStyleBordered target:self action:@selector(myAction)] autorelease];
Appliziner
  • 156
  • 1
  • 3