ios - 处理导航 Controller 中 UIBarButtonItems 的色调颜色变化
<p><p>我正在尝试更改 UIBarButtonItem 的色调颜色。当用户进行选择时,我更改了 tintColor 属性,它工作得很好,但只有当用户在当前屏幕上时。一旦用户将新的 ViewController 推送到堆栈上,更改就不会持续存在。当他们回到屏幕上时,更改后的 tintColor 又回到了原来的状态。我尝试在 viewWillAppear 和 viewDidAppear 中重置属性。依然没有。如果有人可以向我解释发生了什么,将不胜感激!谢谢。</p>
<pre><code>@IBOutlet var dataRunNameBtn: UIBarButtonItem!
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
updateUI()
}
private func updateUI() {
equationType.text = EquationCalculator.sI.equationType
formulaForEquation.text = EquationTableDataSource.sI.formulaText!
self.dataRunNameBtn.title = ClipBoardModel.sI.currentDataRun.name
// Clipboard
if ClipBoardModel.sI.currentDataRunComputed {
self.dataRunNameBtn.tintColor = UIColor.greenColor()
} else {
self.dataRunNameBtn.tintColor = UIColor.flatSandColor()
}
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>打电话</p>
<pre><code>navigationController?.navigationBar.tintColorDidChange()
</code></pre>
<p>在我通过按钮色调更新后为我解决了这个问题!</p></p>
<p style="font-size: 20px;">关于ios - 处理导航 Controller 中 UIBarButtonItems 的色调颜色变化,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/39026593/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/39026593/
</a>
</p>
页:
[1]