iOS navigation bar Navigationbar colors, buttons and captions, and font colors

Source: Internet
Author: User

First, the hierarchical relationship: Leftbarbuttonitem, Rightbarbuttonitem, title are added on the Uinavigationitem, Uinavigationitem added on the Navigationbar, Navigationbar corresponds to the unique navigationcontroller.

1. Set the background color of the navigation bar Navigationbar:

Set after creating Uinavigationcontroller in Appdelegate

(1.) Setbartintcolor: Setting the color of the Nagivationbar can also be used:

[[Uinavigationbarappearance] setbartintcolor:[uicoloryellowcolor]];(in
Uinavigationcontroller execution Pushviewcontroller The interface again setbartintcolor after the color will change, indicating that the same uinavigationbar is set,)

(2) Modify Navigationbar color with Self.navigationController.navigationBar.barTintColor in sub-set

* Remark *//
[Uinavigationbar appearance] method can only be used in Appdelegate, The properties of Nagivationbar can only be modified by Self.navigationcontroller in Uinavigationcontroller's child pages.

(3.) Settintcolor: Set the color of the button on the Nagivationbar:

Self.navigationController.navigationBar.tintColor = [Uicolorbluecolor];


2. Set the color and properties of title on Navigationbar

(1.)

[[Uinavigationbar appearance] Settitletextattributes:@{nsforegroundcolorattributename:[uicolor WhiteColor ]}];


(2.)

[Self.navigationController.navigationBar Settitletextattributes:@{nsforegroundcolorattributename:[uicolor Whitecolor]}];

Also, the knowledge point about the return button:

Set the Back button for the next interface in the previous interface: Self.navigationItem.backBarButtonItem


When you switch to the next view using Pushviewcontroller, the navigation controller changes the left button of the navigation bar in the following 3 order:

1. If b view has a custom left button (Leftbarbuttonitem), the custom button will be displayed;

2. If B does not have a custom button, but the Backbarbuttonitem property of a view has a customization, the customization is displayed;

3, if none of the first 2, then the default display a Back button, the title of the Back button is a view of the title;

iOS navigation bar Navigationbar colors, buttons and captions, and font colors

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.