Several relations of Objective-c:uitoolbar, ToolbarItems and Barbuttonitem

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.