iosxcodeswiftuinavigationbarbartintcolor

UINavigationbar barTintColor not working in UISplitview Template


I am trying for hours to change the Navigationbar barTintValue in my App. I am using the Master-Detail Template from Xcode using Swift and I read a lots of questions here, but the answer was always to use

navigationController?.navigationBar.barTintColor = UIColor.redColor()

This works fine in AppDelegate, but I want to change the color in each DetailView depending on its content at runtime.

When i put this code into the Master or DetailViewController just nothing happens. I printed out the colors before and after and it does set the values, it just doesn't change. Do I need to update the view or something?

Thanks for you help! Maik


Solution

  • As always i just found the answer right after posting this. I don't think its the solution, but its a workaround.

    I change the color for the detailView in prepareForSegue, and change it back to default in the masterViews viewWillAppear.