Hi all,
I created my toolbar on the bottom of the screen above the Tab Bar.
I added a toolbar background but now the button item haven't the same background. They have the default style.
Code:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//Initialize the toolbar
toolbar = [[UIToolbar alloc] init];
toolbar.barStyle = UIBarStyleBlack;
[toolbar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"toolBar.png"]] autorelease] atIndex:0];
//Set the toolbar to fit the width of the app.
[toolbar sizeToFit];
//Calculate the height of the toolbar
CGFloat toolbarHeight = [toolbar frame].size.height;
//Get the bounds of the parent view
CGRect rootViewBounds = self.parentViewController.view.bounds;
//Get the height of the parent view.
CGFloat rootViewHeight = CGRectGetHeight(rootViewBounds);
//Get the width of the parent view,
CGFloat rootViewWidth = CGRectGetWidth(rootViewBounds);
//Create a rectangle for the toolbar
CGRect rectArea = CGRectMake(0, rootViewHeight - toolbarHeight, rootViewWidth, toolbarHeight);
//Reposition and resize the receiver
[toolbar setFrame:rectArea];
//Create a button
UIBarButtonItem *infoButton = [[UIBarButtonItem alloc]
initWithTitle:@"Vedi sulla mappa" style:UIBarButtonItemStyleBordered target:self action:@selector(info_clicked:)];
UIBarButtonItem *calButton = [[UIBarButtonItem alloc]
initWithTitle:@"Ricorda Evento" style:UIBarButtonItemStyleBordered target:self action:@selector(info_clicked:)];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
//self.navigationController.toolbarItems = buttonArray;
[toolbar setItems:[NSArray arrayWithObjects:infoButton, flexibleSpace, calButton, nil]];
[infoButton release];
[flexibleSpace release];
[calButton release];
//Add the toolbar as a subview to the navigation controller.
[self.navigationController.view addSubview:toolbar];
[[self tableView] reloadData];
}
How to solve the issue?