编辑:自定义代码 此问题是由于在应用程序的初始加载期间设置所有对象的 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 错误吗? 奇怪的是,更改不会在切换选项卡后发生,但在不使用 UIAlertViewController 时也不会发生。
最佳答案
尝试设置TintAdjustmentMode
,
[self.view setTintAdjustmentMode:UIViewTintAdjustmentModeNormal];
或
[self.view setTintAdjustmentMode:UIViewTintAdjustmentModeAutomatic];
关于ios - Tintcolor left back arrow navigationBar 在关闭 UIAlertController 后发生变化(IOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39468355/