jxdwinter
jxdwinter

Reputation: 2369

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!

Upvotes: 0

Views: 145

Answers (2)

vishiphone
vishiphone

Reputation: 750

Just edit your code like this and try I think this will work for you.

mCGatherViewController = [[MCGatherViewController alloc] initWithNibName:@"MCGatherViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mCGatherViewController];
navigationController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;

[self.view addSubview:nav.view];

Then you change your Navigation Bar tint color.

Upvotes: 0

Anshuk Garg
Anshuk Garg

Reputation: 1540

just add

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

after

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

in your getToMCGatherViewController method.

Upvotes: 2

Related Questions