标签:
//UIToolBar 是导航控制器默认隐藏的工具条
//设置UIToolBar的隐藏状态
self.navigationController.toolbarHidden = NO;
//如何找到UIToolBar self.navigationController.toolbar
//UIToolBar高度:44
//设置UIToolBar类型:barStyle
self.navigationController.toolbar.barStyle = UIBarStyleDefault;
//设置UIToolBar的颜色:barTintColor
self.navigationController.toolbar.barTintColor = [UIColor redColor];
//设置UIToolBar的图片
[self.navigationController.toolbar setBackgroundImage:[UIImage imageNamed:@"toolBar.png"] forToolbarPosition:UIToolbarPositionBottom barMetrics:UIBarMetricsDefault];
//UIBarButtonItem 文字类型
UIBarButtonItem *wordButton = [[UIBarButtonItem alloc] initWithTitle:@"button" style:UIBarButtonItemStylePlain target:self action:@selector(barButtonClick:)];
//UIBarButtonItem 图片类型
UIBarButtonItem *imageButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"itemImage.png"] style:UIBarButtonItemStylePlain target:self action:@selector(imageButtonClick:)];
//UIBarButtonItem 系统类型
UIBarButtonItem *systemButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(systemButtonClick:)];
//创建空格
//会均分掉空白部分,空格的点击事件不会实现,无效
UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:@selector(spaceClick:)];
//向UIToolBar上面添加按钮 self.toolbarItems
//需要接收数组:数组里面的元素必须是UIBarButtonItem类型
self.toolbarItems = @[space, wordButton, space, imageButton, space, systemButton, space];
标签:
原文地址:http://www.cnblogs.com/hyuganatsu/p/UIToolBar.html