IOS Development Intermediate: Uitoolbar,uinavigationbar,uitabbar,uibarbuttonitem,uitabbaritem Summary of Custom methods

Source: Internet
Author: User

Original: Http://blog.csdn.net/songrotek/article/details/8692866?utm_source=tuicool

For the uitoolbar,uinavigationbar,uitabbar,uibarbuttonitem,uitabbaritem of these kinds of controls, because they are common, they are discussed together.

There are usually two ways to implement customizations.

1) Gets the object of the control and then makes specific modifications to that particular object.

2) The use of uiappearance to achieve all the same control and the specific kind of customization. Since most applications are custom-designed to be aesthetically pleasing, the same controls are essentially the same way of customizing the same class, so using uiappearance to make the customization of the interface very convenient. In this way, it is usually implemented in the APPDELEGATE.M file,

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions Implemented within this method.

Here to introduce the use of uiappearance, referring to the "Uiappearance protocol Reference", there are two ways:

1. Customize the display of all class objects.

[[Uinavigationbar appearance] settintcolor:mycolor];

2. Customize the display of class objects that are contained in a specific containerclass. This is mainly for uibarbuttonitem, which means that some uibarbuttonitem in Uinavigationbar, and some in uitoolbar, we can selectively customize the button in which bar exists. Examples are as follows:

[[Uibarbuttonitem Appearancewhencontainedin:[uinavigationbar class], Nil]settintcolor:mynavbarcolor];

[[Uibarbuttonitem Appearancewhencontainedin:[uinavigationbar Class],[uipopovercontroller class], nil] SetTintColor: Mypopovernavbarcolor];
[[Uibarbuttonitem Appearancewhencontainedin:[uitoolbar class], nil] settintcolor:mytoolbarcolor];

The following summarizes the controls using Uiappearance custom methods. Pick respective Apple's official reference. Note the following methods can also be used separately for a single object.

1, Uitoolbar

customizing appearance

–backgroundimagefortoolbarposition:barmetrics: (Page 7)
Returns the image to use for the background in a given position and with given metrics.

–setbackgroundimage:fortoolbarposition:barmetrics: (Page 7)
Sets the image to use for the background in a given position and with given metrics.

–shadowimagefortoolbarposition: (page 9)
Returns the image to use for the toolbar shadow in a given position.

–setshadowimage:fortoolbarposition: (page 9)
Sets the image to use for the toolbar shadow in a given position.

Tintcolor (page 6) Property
The color used to tint the bar.

2, Uitabbar

customizing appearance

BackgroundImage (page 5)property of the background image for the bar.

Selectedimagetintcolor (page 7) property
The tint color to apply to the gradient image used when creating the selected image.

Selectionindicatorimage (page 8) property of the image used for the selection indicator.

ShadowImage (page 8) Property
The shadow image to is used for the tab bar.

Tintcolor (page 8) Property
The tint color to apply to the tab bar background.

3, Uinavigationbar

Customizing the Bar appearance

Tintcolor (page 9) Property
The color used to tint the bar.

–backgroundimageforbarmetrics: (PAGE11)
Returns the background image for given bar metrics.

–setbackgroundimage:forbarmetrics: (page) sets the background image for given bar metrics.

–titleverticalpositionadjustmentforbarmetrics: (page) Returns the title ' s vertical position adjustment for given bar me Trics.

–settitleverticalpositionadjustment:forbarmetrics: (page) sets the title ' s vertical position adjustment for given bar m Etrics.

Titletextattributes (page 9) property Display attributes for the bar ' s title text.

4, Uibarbuttonitem

customizing appearance

Tintcolor (page 9) Property
The tint color for the button item.

–backbuttonbackgroundimageforstate:barmetrics: (page 10)

Returns the Back button background image for a given control state and bar metrics.

–setbackbuttonbackgroundimage:forstate:barmetrics: (Page 17)

Sets the back button background image for a given control state and bar metrics

–backbuttontitlepositionadjustmentforbarmetrics: (PAGE11) Returns the back button title, offset for given bar metrics.

–setbackbuttontitlepositionadjustment:forbarmetrics: (page) sets the back button title, offset for given bar metrics

–backbuttonbackgroundverticalpositionadjustmentforbarmetrics: (page) Returns the Back button vertical position Offset for given bar metrics.

–setbackbuttonbackgroundverticalpositionadjustment:forbarmetrics: (page) sets the back button vertical position Offset for given bar metrics.

–backgroundverticalpositionadjustmentforbarmetrics: (page) Returns the background vertical position offset for given Bar metrics.

–setbackgroundverticalpositionadjustment:forbarmetrics: (page) sets the background vertical position offset for given Bar metrics.

–backgroundimageforstate:barmetrics: (PAGE11)

Returns the background image for a given state and bar metrics.

–setbackgroundimage:forstate:barmetrics: (page 19)

Sets the background image for a given state and bar metrics.

–backgroundimageforstate:style:barmetrics: (Page 12)

Returns the background image for the specified state, style, and metrics.

–setbackgroundimage:forstate:style:barmetrics: (page 20)

Sets the background image for the specified state, style, and metrics.

–titlepositionadjustmentforbarmetrics: (page) Returns the title offset for given bar metrics.

–settitlepositionadjustment:forbarmetrics: (page) sets the title offset for given bar metrics.

5, Uitabbaritem

customizing appearance

–titlepositionadjustment (page 8)
Returns the offset to adjust the title position.

–settitlepositionadjustment: (page 8)
Sets the offset to adjust the title position.

In addition, it is custom-made for specific objects.

1, Uitabbaritem

–finishedselectedimage (page 5) Returns the finished selected image.

–finishedunselectedimage (page 5) Returns the finished unselected image.

–setfinishedselectedimage:withfinishedunselectedimage: (page 7) sets the finished selected and unselected images.

The above method is used to change each individual Tabbaritem selected and unchecked image

2, Uibarbuttonitem

Style (page 8)Property The style of the item.

Possibletitles (page 7) property
The set of possible titles to display on the bar button.

Width (page 9)Property The width of the item.

CustomView (page 7) property
A Custom view representing the item.

3, Uinavigationbar

Barstyle (page 7) property
The appearance of the navigation bar.

ShadowImage (page 8) Property
The shadow image to is used for the navigation bar.

Translucent (page) property
A Boolean value indicating whether the navigation bar is only partially opaque.

Basically, it's easy to customize it by taking care of these methods.

IOS Development Intermediate: Uitoolbar,uinavigationbar,uitabbar,uibarbuttonitem,uitabbaritem Summary of Custom methods

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.