UINavigationbar barTintColor 在 UISplitview 模板中不起作用 [英] UINavigationbar barTintColor not working in UISplitview Template
问题描述
我尝试了几个小时来更改我的应用程序中的导航栏 barTintValue.我正在使用 Xcode 中的 Master-Detail 模板,使用 Swift 和我在这里阅读了很多问题,但答案总是使用
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()
这在 AppDelegate 中运行良好,但我想在运行时根据其内容更改每个 DetailView 中的颜色.
This works fine in AppDelegate, but I want to change the color in each DetailView depending on its content at runtime.
当我将此代码放入 Master 或 DetailViewController 时,什么也没有发生.我打印了之前和之后的颜色,它确实设置了值,只是没有改变.我需要更新视图还是什么?
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?
谢谢你的帮助!迈克
推荐答案
和往常一样,我在发布此内容后立即找到了答案.我认为这不是解决方案,而是一种解决方法.
As always i just found the answer right after posting this. I don't think its the solution, but its a workaround.
我在 prepareForSegue 中更改了 detailView 的颜色,并在 masterViews viewWillAppear 中将其改回默认值.
I change the color for the detailView in prepareForSegue, and change it back to default in the masterViews viewWillAppear.
这篇关于UINavigationbar barTintColor 在 UISplitview 模板中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!