UI控件(UIToolbar)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UI控件(UIToolbar)相关的知识,希望对你有一定的参考价值。
@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)的主要内容,如果未能解决你的问题,请参考以下文章
UIToolbar 异常胖 UISegmentedControl