ツールバーオブジェクトを作成し、そのツールバーにボタンを追加し、このツールバーとして右バーボタンアイテムまたは左バーボタンアイテムのカスタムビューを設定できます。
サンプルの実装は次のとおりです。
UIToolbar * toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0,0,160, 44.5)];
UIBarButtonItem *spacer = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
[buttons addObject:spacer];
[spacer release];
UIBarButtonItem * deleteButton = [[UIBarButtonItem alloc]
initWithTitle:@"Delete"
style:UIBarButtonItemStyleBordered
target:self
action:@selector(deletePressed)];
// Button style is the default style
[buttons addObject:deleteButton];
[deleteButton release];
UIBarButtonItem * barItem = [[UIBarButtonItem alloc] initWithTitle:@"Logout" style:UIBarButtonItemStyleBordered
target:[Y3AppDelegate mainApplicationInstance] action:@selector(logout)];
[buttons addObject:barItem];
[barItem release];
// put the buttons in the toolbar and release them
[toolbar setItems:buttons animated:YES];
[buttons release];
// place the toolbar into the navigation bar as Right Button item
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]
initWithCustomView:toolbar] autorelease];
[toolbar release];
ここで注目すべきことは、ツールバーの色をナビゲーションバーの色調に合わせて変更する必要があることです。この答えがあなたに役立つことを願っています。