1

I am able to change the navbar color of the More navigationcontroller via:

stTabBarController.moreNavigationController.navigationBar.tintColor = [UIColor colorWithRed:(102.0/255.0) green:(20.0/255.0) blue:(11.0/255.0) alpha:1];

but when I click the Edit button, the Configure screen appears and the navbar color is the default blue. How can I change this color?

Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556

3 Answers3

2

Solved it:

#pragma mark UITabBarControllerDelegate
- (void)tabBarController:(UITabBarController *)controller willBeginCustomizingViewControllers:(NSArray *)viewControllers {
    UIView *editViews = [controller.view.subviews objectAtIndex:1];
    UINavigationBar *editModalNavBar = [editViews.subviews objectAtIndex:0];

    editModalNavBar.tintColor = [UIColor colorWithRed:(102.0/255.0) green:(20.0/255.0) blue:(11.0/255.0) alpha:1];

}
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
  • I did seem to get UINavigatonBar at index 0. While loging subviews found out it was at index at 1 (working on iOS 8.). – Dipu Rajak Mar 23 '15 at 19:49
0

@Sheehan Alam solution did not work for me (working on iOS 8). Anyway I got 2/3 of the solution from his answers. I am posting this to improve the answer.

#prama mark - UITabBarControllerDelegate
- (void)tabBarController:(UITabBarController *)tabBarController willBeginCustomizingViewControllers:(NSArray *)viewControllers {

   UIView *editViews = [tabBarController.view.subviews objectAtIndex:1];

   for (UIView * view in [editViews subviews]) {
       if ([view isKindOfClass:[UINavigationBar class]]) {
           UINavigationBar *editNavBar = (UINavigationBar *)view;
           editNavBar.barTintColor = [UIColor redColor];
       }
   }
}
Dipu Rajak
  • 693
  • 5
  • 15
0

To anyone else with this question, in order for Sheehan Alam's solution to work, you need to make sure you set the tabBarController's delegate to self within the viewDidLoad method like so:

- (void)viewDidLoad {
  ...
  self.delegate = self;
  ...
}

Then you need to make sure your tabBarController conforms to the UITabBarControllerDelegate protocol like so:

@interface TabBarController : UITabBarController <UITabBarControllerDelegate> {
  ...
} 

Otherwise the method he's overriding won't be called.

Philip Walton
  • 29,693
  • 16
  • 60
  • 84