Toolbar: ToolBar
Toolbar item: Bar Button Itemfixed adjustment of the adjustment button position: fixed Space Bar button Itemflexible adjustment of the adjustment button position: Flexible Space Bar button The toolbar toolbar is a property of the views view, and you can add toolbar buttons to the toolbar button Item (either custom or system-brought Barbuttonsystemitem). The view controller can manipulate the contents of the image from the toolbar item. buttons Bar button item has three kinds of Style:Plain (can use custom picture),boarded and done . Other properties are words too literally. To make the button unavailable, change the enable property. Tool Bar can also make some adjustments (mainly to adjust style). It is important to note that abutton of type Plain is not a title, that is, Null. to illustrate, theFixed space bar button item is a constant (also adjustable) spacing, while the flexible space bar button item automatically adjusts the existing button to maximize the space of the toolbar. The point is: We can use ToolbarItems to set the button on the toolbar, the General app see there are 3-4 options such as "Home", "settings" These can be loaded as Uibarbuttonitem object on this toolbar, of course, From the ToolbarItems name, it has a "s", so we have to separate the Uibarbuttonitem object into an array, and then assign this array to ToolbarItems. Or, use the Settoolbaritems method to add all the tool items to the toolbar. For example, to set the display item of a toolbar by ToolbarItems, an instance of Uibarbuttonitem in the array//barbuttonitem Instances
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];
//Put toolbar items: Barbuttonitem and adjustment instances into the array
Nsarray *arr1=[[nsarray Alloc]initwithobject:item1,spaceitem,item2,spaceitem,nil];
Placing a button on a toolbar with the ToolbarItems property
Self.toolbaritems = arr;
or put the button on the toolbar with the Settoolbaritems method
[self Settoolbaritems:arr];
Several relations of Objective-c:uitoolbar, ToolbarItems and Barbuttonitem