不疯不成魔

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //显示toolbar
    //self.navigationController.toolbarHidden = NO;
    
    //动画效果
    [self.navigationController setToolbarHidden:NO animated:YES];
    
    //背景颜色
    self.navigationController.toolbar.barTintColor = [UIColor redColor];
    
    //渲染颜色
    self.navigationController.toolbar.tintColor = [UIColor orangeColor];
    
    //设置背景图片
    [self.navigationController.toolbar setBackgroundImage:[UIImage imageNamed:@"123.jpg"] forToolbarPosition:UIBarPositionBottom barMetrics:UIBarMetricsDefault];
    
    
    UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(handle:)];
    
    
    
    UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(handle:)];
    
    UIBarButtonItem *item3 = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"234.jpg"] style:UIBarButtonItemStylePlain target:self action:@selector(handle:)];
    
    
    UIBarButtonItem *item4 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:@selector(handle:)];
    //UIBarButtonItem *item4 = []
    self.toolbarItems = @[item1,item4,item2,item4,item3,item4];
    
//    UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(20, 100, 300, 30)];
//    [self.view addSubview:toolBar];
//    toolBar.backgroundColor = [UIColor redColor];
//    toolBar.items = @[item1,item2];
    
}

- (void)handle:(UIBarButtonItem *)item{
    NSLog(@"gogogogo");
}
@end

 

posted on 2015-09-17 22:36  不疯不成魔  阅读(210)  评论(0编辑  收藏  举报