首页 > 其他 > 详细

UI控件(UIToolbar)

时间:2016-02-22 22:02:25      阅读:121      评论:0      收藏:0      [点我收藏+]
@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _toolbar = [[UIToolbar alloc]init];
    _toolbar.frame = CGRectMake(0, 0, 320, 45);
    
    //以标题命名的按钮
    _barItem = [[UIBarButtonItem alloc]
        initWithTitle:@"Item1" style:UIBarButtonItemStyleDone target:self action:@selector(doClick)];
    
    //以图片作为背景的按钮
    UIImage *_image = [UIImage imageNamed:@"fresh.png"];
    _barItem1 = [[UIBarButtonItem alloc]
                initWithImage:_image style:UIBarButtonItemStylePlain target:self action:@selector(doClick)];
    
    NSMutableArray *array = [NSMutableArray array];
    [array addObject:_barItem];
    [array addObject:_barItem1];
    
    //在工具栏中添加按钮
    [_toolbar setItems:array animated:YES];
    
    [self.view addSubview:_toolbar];
    
}

-(void)doClick{
    NSLog(@"doClick");
}

@end

 

UI控件(UIToolbar)

原文:http://www.cnblogs.com/Fredric-2013/p/5208197.html

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