ios - Tintcolor left back arrow navigationBar 在关闭 UIAlertController 后发生变化(IOS)

标签 ios swift navigationbar tintcolor

编辑:自定义代码 此问题是由于在应用程序的初始加载期间设置所有对象的 tintColor 引起的。


我的代码中有一个非常奇怪的情况。左后退箭头的 tintColor 在之后更改为另一种颜色:

  1. 呈现 UIAlertController
  2. 关闭 UIAlertController
  3. 切换标签。 (标签切换时可以看到颜色变化)。

更改颜色后,无法设置回原来的颜色。

我尝试了什么?

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/

相关文章:

iphone - 在 iOS 的更新过程中,系统是否会杀死后台/内存中的应用程序?

parse-platform - 使用 Swift 1.2 注册解析用户

ios - Swift 2.0 Alamofire 完成处理程序返回 Json

ios - 无法以编程方式向按钮添加约束 - Swift 2.0

SwiftUI 将当前 View 中导航栏按钮的文本标题更改为 "Back",而不是继承前一个 View 标题中的文本

ios - 如何在 Swift 2.0 中将 UITextField 转换为整数?

ios - 模拟器中的数组大小与 iphone 中的数组大小不同

ios - 快速弹出UIView的动画

html - 在页面中心对齐导航栏

html/css 垂直导航栏