编辑:自定义代码
这个问题是由于在应用程序的初始加载期间设置了所有对象的tintColor引起的。
我的代码出现了一个非常奇怪的情况。在以下操作后,左侧返回箭头的tintColor会改变为另一种颜色:
- 呈现UIAlertController
- 关闭UIAlertController
- 切换标签页(颜色变化可以在标签切换期间看到)。
颜色变化后,我无法将其恢复为原始颜色。
我尝试了什么?
1)在多个位置上重新设置颜色。(ViewWillAppear / ViewDidAppear)。
self.navigationItem.backBarButtonItem?.tintColor = UIColor.redColor()
self.navigationController?.navigationBar.tintColor = UIColor.redColor()
2)设置外观。
UINavigationBar.appearance().tintColor = UIColor.yellowColor()
3) 尝试重写didSetTintColor方法
4) 在释放UIAlertView后更改tintColor(如下示例)
UIAlertAction(title: "Example button", style: .Cancel, handler: { action in
alertController.removeFromParentViewController()
self.navigationItem.backBarButtonItem?.tintColor = UIColor.greenColor()
self.navigationController?.navigationBar.tintColor = UIColor.greenColor()
})
5) 尝试了这个解决方案:Navigation bar tint color changes after auto dimissal of UIAlertView
似乎没有什么作用。这可能是IOS的一个bug吗? 奇怪的是,切换选项卡后不会发生更改,但不使用UIAlertViewController时也不会发生更改。