Search code examples
iosuinavigationcontrolleruitabbarcontrolleruicolor

How to change the color of UITabbarViewController's navigationBar?


There is a UITabBarController

- (void)getToMCGatherViewController
{
    mCGatherViewController = [[MCGatherViewController alloc] initWithNibName:@"MCGatherViewController" bundle:nil];
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mCGatherViewController];
    navigationController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:navigationController animated:YES];
    [navigationController release];
}

In the .h file:

 @interface MCGatherViewController : UITabBarController

In the .m file . I want to change the color of the view's navigationBar

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navigationController.navigationBar.tintColor=[UIColor greenColor];
}

and it does not work at all.

Help me with this problem , thank you in advance!


Solution

  • just add

    [navigationController.navigationBar setTintColor:[UIColor greenColor]];
    

    after

    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mCGatherViewController];
    

    in your getToMCGatherViewController method.