The Uitoolbar exists in the Uinavigationcontroller navigation bar controller and is hidden by default. Toolbar is displayed when the settings Uitoolbar display, or if there is Uitabbarcontroller and Tabbar is hidden. We use Uitoolbar because it is always displayed at the bottom of the screen, and sometimes we need to add a button or a message at the bottom of the screen without having to create another uiview or other view. Because creating UIView or other views needs to fit the screen size, it also hides the bottom view display, resulting in incomplete display situations, etc. So it is necessary to learn to use Uitoolbar.
Create Project and view controllers
1, create a empty (empty) project, a new Uiviewcontroller;
2, select the project, right-click-new File ... Select "Cocoa Touch Class"-next, give a reasonable name Viewcontroller, then Next complete;
3, in the APPDELEGATE.M file contains #import "ViewController.h";
4. Initialize the view controller that created the Viewcontroller and include it with the navigation bar controller. Set it to the root view controller.
Understanding and displaying Uitoolbar
1, Uitoolbar is a bar in the Uinavigationcontroller;
2, need to display uitoolbar need to create uinavigationcontroller;
3, by the method/step 1 is visible, Uinavigationcontroller navigation bar controller has been created;
4. Set the Toolbarhidden property of Uinavigationcontroller to display Uitoolbar.
Set the Uitoolbar property (used after iOS7)
1, set the trace color: bartintcolor;
2, set the background image: SetBackgroundImage:forToolbarPosition:barMetrics:.
Create Uibarbuttonitem
1, Uitoolbar on the display is uibarbuttonitem;
2, the creation of commonly used class 4 Uibarbuttonitem;
3, each Uibarbuttonitem Add Agent response event method;
4. Set the tag ID of the Uibarbuttonitem.
Note: When Uibarbuttonitem is a picture, be aware that there is no translucent effect.
Add Uibarbuttonitem for Uitoolbar
1, create an array itemsarray;
2, add Uibarbuttonitem on the array;
3, the Itemsarray passed to UIToolBar:self.toolbarItems = Itemsarray.
Implementing the Uibarbuttonitem Agent response event method
-(void) Toolbaraction: (uibarbuttonitem*) sender;
Finish effect
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Use of IOS Uitoolbar