UINavigationController and UITabbarController

Source: Internet
Author: User

UINavigationController and UITabbarController

Although the two central view controllers have been written in hand before, we still use SB to create more controllers. Recently, we have found some problems. Now let's summarize them.

 

1. Change the UINavigationBar color

In UINavigationController, you only need to set UINavigationController. navigationBar. tintColor to change the color of navigationBar. In the latest API, Apple can modify this attribute.

A barTintColor attribute is added. The previous tintColor does not affect the bar color. To change the color, you need to use barTintColor.

 

2. Set the title of UINavigationBar and the item text in UITabBarController to different titles.

When a View Controller is the current controller of UINavigationController and the self. title attribute is set, the title of the navigationBar of the current view will automatically obtain the value of self. title. If the current view controller is still in tabBarController, the title of the following item will also be self. title, if you want the text on the bar to be different from the text on the item, you need to set the text on the bar separately, that is, in addition to setting self. the title should also be set in self. navigationItem. title value. You can modify the title above bar and set the text on item separately, self. navigationController. tabbarItem. you can modify this attribute by title.

 

3. Custom UINavigationBar intermediate View

UINavigationBar has a titleView attribute. You can customize the view to place it in the middle. For example, you can place the wait indicator here.

 

4. Change the text style of UINavigationBar title

UINavigationBar has a property of titleTextAttributes. For example, to set the text to '18 red', you can use NSFontAttributeName and NSForegroundColorAttributeName to set the text style and color respectively.

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.