AppDelegate.m设置windows根视图控制器
RootViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
/*_______________________UIToolBar工具栏的使用____________________________*/
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 50, 30);
//设置标题
[button setTitle:@"按钮" forState:UIControlStateNormal];
[button setTitle:@"点击了" forState:UIControlStateHighlighted];
//创建item
UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithCustomView:button];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"标题" style:UIBarButtonItemStyleBordered target:self action:@selector(touchAction)];
UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(touchAction)];
//创建一个空格
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc] initWithCustomView:view];
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(10, 200, 300, 44)];
//设置工具栏的样式
toolBar.barStyle = UIBarStyleBlack;
[self.view addSubview:toolBar];
toolBar.items = @[item1,item2,spaceItem,item3];
}