Reputation: 10938
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.
Upvotes: 1
Views: 2013
Reputation: 326
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.
Upvotes: 2
Reputation: 2574
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;
}
Upvotes: 0
Reputation: 10938
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.
Upvotes: 3