//1.创建toolbar(MyToolbar继承UIToolbar)
_myToolbar = [[MyToolbar alloc]initWithFrame:CGRectMake(kZero, kZero, kScreenW, kToolbarH)];
_myToolbar.backgroundColor = [ColorTools toolbarColor]; //2.创建左右两边的buttonItem
_leftButton = [[UIButton alloc]initWithFrame:CGRectMake(, , , )];
[_leftButton setImage:[UIImage imageNamed:@"left"] forState:UIControlStateNormal];
[_leftButton setImage:[UIImage imageNamed:@"left_Highlight"] forState:UIControlStateHighlighted];
[_leftButton addTarget:self action:@selector(left) forControlEvents:UIControlEventTouchUpInside]; _rightButton = [[UIButton alloc]initWithFrame:CGRectMake(, , , )];
[_rightButton setImage:[UIImage imageNamed:@"right"] forState:UIControlStateNormal];
[_rightButton setImage:[UIImage imageNamed:@"right_Highlight"] forState:UIControlStateHighlighted];
[_rightButton addTarget:self action:@selector(right) forControlEvents:UIControlEventTouchUpInside]; //3.创建中间的label
_titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(, kStatusH, , )];
_titleLabel.text = @"测试Toolbar";
_titleLabel.textColor = [UIColor whiteColor]; //4.添加到当前视图中
[_myToolbar addSubview:_titleLabel];
[_myToolbar addSubview:_leftButton];
[_myToolbar addSubview:_rightButton];
[self.view addSubview:_myToolbar];