Use of IOS Uitoolbar

Source: Internet
Author: User

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.

  1. 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.

  2. 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.

  3. Set the Uitoolbar property (used after iOS7)

    1, set the trace color: bartintcolor;

    2, set the background image: SetBackgroundImage:forToolbarPosition:barMetrics:.

  4. 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.

  5. Add Uibarbuttonitem for Uitoolbar

    1, create an array itemsarray;

    2, add Uibarbuttonitem on the array;

    3, the Itemsarray passed to UIToolBar:self.toolbarItems = Itemsarray.

  6. Implementing the Uibarbuttonitem Agent response event method

    -(void) Toolbaraction: (uibarbuttonitem*) sender;

  7. Finish effect



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Use of IOS Uitoolbar

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.