iosobjective-cios7uinavigationbarbartintcolor

Change the barTintColor after page load


Every view in my app has a different color. Setting this color works great. However, when I push to the next view (with its own color) and then return to the previous view.. the root view has a navbar BarTintColor set to the view I pushed to.

E.g.:
Root view (red) > About view (green) > (back to root) Root view (green)

How can I set the barTintColor when the page is already loaded? I have tried it using - (void)viewWillAppear:(BOOL)animated but it doesn't change back.


Solution

  • On each of your view controllers , you can use following code in viewDidAppear: method :

        [self.navigationController.navigationBar setBarTintColor:[UIColor redColor]]; // Your Desired Color
        [self.navigationController.navigationBar setNeedsDisplay];