BenLeim BenLeim - 1 year ago 82
iOS Question

iOS Different navigation bar color on different pages

How would I change the navigation bar color based on what page the user is on?

I would like to do something similar to what the Vine app uses in the explore category when the user taps a certain category and it turns into the color of the button in a fading format. Any thoughts on how to do this?

Answer Source

You can try to set the navigation bar tint color in the prepareForSegue: method (in your controller whit the four buttons) like this

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:"segueIdentifier here"]) { [self.navigationController.navigationBar setBarTintColor:[UIColor redColor]]; } }

Don't forget to reset the navigation bar tint color when you came back (do this in the viewWillAppear)

Or you can try to do this in all your controllers in the method viewWillAppear: like this

- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.navigationController.navigationBar setBarTintColor:[UIColor redColor]]; }

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download