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.