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, so there is no need to create another uiview or other view.
Because creating UIView or other views needs to fit the screen size. Also hides the bottom view display. Cause incomplete display of the situation and so on. So it is necessary to learn to use Uitoolbar.
To create a project project and a view controller
1. Create an empty project project, creating a new Uiviewcontroller;
2. Select Project. Right-click-new File ... Select "Cocoa Touch Class"-next, give a reasonable name Viewcontroller, then Next complete;
3. The appdelegate.m file includes #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 show uitoolbar is required to create uinavigationcontroller;
3, by 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 the Uibarbuttonitem.
2, create the frequently used 4 class Uibarbuttonitem.
3, each Uibarbuttonitem to join the 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.
Join Uibarbuttonitem for Uitoolbar
1. Create an array of 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.
Finished effect
Use of IOS Uitoolbar