UINavigationbar barTintColor not working in UISplitview Template

不想你离开。 提交于 2019-12-11 07:48:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!