Pergunta

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.

Foi útil?

Solução

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];

Outras dicas

Maybe use one of the Unwind Segue mechanisms (like put the unwind segue in your prepareForSegue: or use a delegate and execute it before your unwind happens...Make sense or do I need to go deeper?

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top