IOSでtoolbar(ツールバー)の操作

 

self.navigationItem.title=@"ツールバーを表示";
// ツールバーを表示
//self.navigationController.toolbarHidden = NO;
[self.navigationController setToolbarHidden:NO];

//toolbarの背景画像を設定
//[self.navigationController.toolbar setBackgroundImage:[UIImage imageNamed:@"1.jpg"] forToolbarPosition:UIToolbarPositionBottom barMetrics:UIBarMetricsDefault];

self.navigationController.toolbar.frame = CGRectMake(0, 0, 320, 44);

//toolbaritemsでツールバーオプションを表示 配列UIBarButtonItem
UIBarButtonItem *item1 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:nil];

//itemの間隔 自動的に間隔を計算
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
NSArray *items = [NSArray arrayWithObjects:spaceItem, item1,spaceItem,item2,spaceItem, nil];

IOS

Posted by arkgame