1

I am trying to set all my tab bar's navigation bars UIBarStyleBlack.

I could also achieve this for the "more" tab bar with this:

tabBarController.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack;

The problem is that when you click its top Edit button to customize the tabs it presents a new modal controller with a standard blue navigation bar, and I can't manage to set it UIBarStyleBlack.

Rivera
  • 10,792
  • 3
  • 58
  • 102
  • Found this page [link](http://runmad.com/blog/2010/01/coloring-fun-with-morenavigationcontroller-and-it/) – Rivera Nov 22 '11 at 01:46
  • Seems like I can catch the modal edit view implementing this tab bar delegate method - (void)tabBarController:(UITabBarController *)controller willBeginCustomizingViewControllers:(NSArray *)viewControllers – Rivera Nov 22 '11 at 01:47

3 Answers3

3

The link has a slightly hackie solution that involves listening to when the modal view will appear.

Colouring fun with moreNavigationController

Until iOS5+ enables us to do it in a cleaner way.

Rivera
  • 10,792
  • 3
  • 58
  • 102
  • done it in a major app and did not get rejected -> works fine. – Till Dec 13 '11 at 02:11
  • It's not really that hacky. It's not like you're swizzling or using private APIs. Anyway, just wanted to comment that all this can be done with UIAppearance on iOS 5 and up. – runmad Sep 22 '12 at 16:13
2

Swift - customizing Tabbar -> More menu -> Edit view (navigation bar and content view).

override func tabBar(_ tabBar: UITabBar, willBeginCustomizing items: [UITabBarItem]) {
    for (index, subView) in view.subviews.enumerated() {
        subView.backgroundColor = UIColor.black
        if index == 1 {
            subView.tintColor = UIColor.green
            for customSubView in subView.subviews {
                if let navBar = customSubView as? UINavigationBar {
                    navBar.isTranslucent = false
                    navBar.barTintColor = UIColor.black
                    navBar.tintColor = .white
                }
            }
        }
    }
}

This is what worked for me.

Arijan
  • 297
  • 3
  • 6
0

Sublcass UITabBarController and overwrite these methods:

- (void)tabBar:(UITabBar *)tabBar willEndCustomizingItems:(NSArray<UITabBarItem *> *)items changed:(BOOL)changed {
    self.moreNavigationController.navigationBar.barStyle = UIBarStyleBlack;
}

- (void)tabBar:(UITabBar *)tabBar didBeginCustomizingItems:(NSArray<UITabBarItem *> *)items {
    self.moreNavigationController.navigationBar.barStyle = UIBarStyleDefault;
}
gklka
  • 2,459
  • 1
  • 26
  • 53