首页 > 移动平台 > 详细

iOS中的UIToolBar

时间:2015-09-17 23:04:17      阅读:368      评论:0      收藏:0      [点我收藏+]
#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

 

iOS中的UIToolBar

原文:http://www.cnblogs.com/wohaoxue/p/4817877.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!