iOS Basics-System comes with button style-Uibarbuttonsystemitem

Source: Internet
Author: User

System button

In addition to the image and text buttons, there is a small library of system buttons that can create standardized, predefined buttons that you can see in many applications. System buttons are also uibarbuttonitem objects that can be created through the Initwithbarbuttonsystemitem method of the class. The following example:

    1. Uibarbuttonitem *mybookmarks = [[Uibarbuttonitem alloc]
    2. Initwithbarbuttonsystemitem:uibarbuttonsystemitembookmarks
    3. Target:self
    4. Action: @selector (Myselector:)
    5. ];

Table 3-2 is the currently supported system button that can be found in the UIBarButtonItem.h header file.

Table 3-2

button identifiers

Description

Uibarbuttonsystemitemdone

Blue text button labeled "Done"

Uibarbuttonsystemitemcancel

Text button, labeled "Cancel"

Uibarbuttonsystemitemedit

Text button, labeled "Edit"

Uibarbuttonsystemitemsave

Blue text button labeled "Save"

Uibarbuttonsystemitemadd

Image button with a å symbol on it

Uibarbuttonsystemitemflexiblespace

Blank, variable space-occupying size

Uibarbuttonsystemitemfixedspace

Blank placeholder

Uibarbuttonsystemitemcompose

Image button with a pen and paper on it

Uibarbuttonsystemitemreply

Image button with a reply arrow on it

Uibarbuttonsystemitemaction

Image button with an action arrow on it

Uibarbuttonsystemitemorganize

Image button, with a folder on it and a down arrow

Uibarbuttonsystemitembookmarks

Image button with bookmark icon on it

Uibarbuttonsystemitemsearch

Image button with Spotlight icon on it

Uibarbuttonsystemitemrefresh

Image button with a circular flush arrow on it

Uibarbuttonsystemitemstop

Image button with a stop mark on the X

Uibarbuttonsystemitemcamera

Image button with a camera on it

Uibarbuttonsystemitemtrash

Image button with a trash bin on it

Uibarbuttonsystemitemplay

Image button with a play icon on it

Uibarbuttonsystemitempause

Image button with a pause icon on it

Uibarbuttonsystemitemrewind

Image button with a rewind icon on it

Uibarbuttonsystemitemfastforward

Image button with a fast forward icon


Custom View Buttons

Like the navigation bar, a button can also be drawn according to a custom view class so that you can display any other type of view object as a button:

    1. Uibarbuttonitem *custombutton = [[Uibarbuttonitem alloc]
    2. Initwithcustomview:myview];

Creating toolbars

Add all the buttons you want to display to the buttons array you created earlier:

    1. [Buttons Addobject:buttonimage];
    2. [Buttons Addobject:buttontext];
    3. [Buttons Addobject:mybookmarks];

Next, create a Uitoolbar object and assign your button array to the toolbar as a list of items:

    1. Uitoolbar *toolbar = [[Uitoolbar alloc] init];
    2. [Toolbar setitems:buttons Animated:yes];

Finally, replace the title view of your navigation bar with the newly created toolbar, just as you would replace a component segment control:

    1. Self.navigationItem.titleView = toolbar;

When the navigation bar is displayed, the toolbar appears in its center.

Adjust size

The toolbar will apply the default size to the added buttons. If you want to adjust the toolbar so that it fits neatly into the size of the navigation bar, you can use the SizeToFit method:

    1. [Toolbar SizeToFit];

The style of the toolbar

Just like many other view-based objects, Uitoolbar also contains a style attribute named Barstyle. This property can be used to adjust the style of the toolbar so that it matches the style you define for the navigation bar:

    1. Toolbar.barstyle = Uibarstyledefault;

You can set the style of the toolbar to one of three standard style themes that are also used by most other types of column objects, as shown in table 3-3.

Table 3-3

Style

Description

Uibarstyledefault

Default style: Gray background, white text

Uibarstyleblackopaque

Pure black background, white text

Uibarstyleblacktranslucent

Transparent black background, white text

iOS Basics-System comes with button style-Uibarbuttonsystemitem

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.