标签:
工具栏:ToolBar
UIBarButtonItem *item1 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:nil];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:nil];
//item的间隔,不会显示出来,会自动计算间隔,就是上面的调节
UIBarButtonItem *spaceItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil];
NSArray *arr1=[[NSArray alloc]initWithObject:item1,spaceItem,item2,spaceItem,nil];
//通过toolbarItems属性将按钮放入到工具栏上
self.toolbarItems = arr;
或者通过setToolbarItems方法将按钮放入到工具栏上
[self setToolbarItems:arr];
Objective-C:UIToolBar、toolbarItems、BarButtonItem的几种关系
标签:
原文地址:http://www.cnblogs.com/XYQ-208910/p/4771811.html