问题
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
回答1:
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.
回答2:
I faced same problem. I have found a solution.
navigationController?.navigationBar.backgroundColor = UIColor.redColor()
来源:https://stackoverflow.com/questions/26256149/uinavigationbar-bartintcolor-not-working-in-uisplitview-template