Swift changes the style of the navigation bar (text color, background color, background picture)

Source: Internet
Author: User

By default, the style of the navigation bar Uinavigationcontroller is simpler if you want to use code to modify the style.

1, modify the navigation bar background color


Modify the navigation bar background color
Self.navigationcontroller? Navigationbar.bartintcolor =
Uicolor (red:55/255, green:186/255, blue:89/255, alpha:1)

2, modify the navigation bar text color

//Modify navigation bar text color
Self.navigationcontroller? Navigationbar.titletextattributes =
    [nsforegroundcolorattributename: Uicolor.whitecolor ()]

 

3, modify navigation bar button Color
Regardless of the default button, or a custom button, colors are modified.

//Modify navigation bar button Color
Self.navigationcontroller? Navigationbar.tintcolor = Uicolor.whitecolor ()

4, modify navigation bar background picture
If the background picture does not need to extend to the status bar, the background picture height is 44 points (88 pixels).


If you want the navigation bar to be included in the background picture, the background picture height is changed to 64 dots (128 pixels).

Regardless of size, the setting code is as follows:

Self.navigationco Ntroller? Navigationbar
            .setbackgroundimage ( UIImage (named: "Bg5"), Forbarmetrics:. Default)

Related Article

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.