UIAlertController关闭后,导航栏左侧返回箭头的Tint颜色发生了变化(IOS)

3
编辑:自定义代码 这个问题是由于在应用程序的初始加载期间设置了所有对象的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的一个bug吗? 奇怪的是,切换选项卡后不会发生更改,但不使用UIAlertViewController时也不会发生更改。


返回的图标颜色是什么?黄色的吗? - Chathuranga Silva
正常的颜色是UIColor.whiteColor()。(我尝试设置不同的颜色,以找到代码中正确的位置)。颜色被改变为blueColor。(这是应用程序的默认Tintcolor) - Bas
展示切换选项卡的代码 - Chathuranga Silva
我编辑了这篇文章! - Bas
2个回答

0
尝试设置 TintAdjustmentMode
 [self.view setTintAdjustmentMode:UIViewTintAdjustmentModeNormal];

或者

 [self.view setTintAdjustmentMode:UIViewTintAdjustmentModeAutomatic];

嗨 Lion,我尝试了这个(也在AlmanappDelegate.swift中)。没有任何改变。当我将它设置为.Normal时,从一开始就显示了错误的颜色。 - Bas

0
我找到了问题所在。在应用程序委托中,一个函数设置了整个应用程序的所有tintColor。显然,ActionController的关闭将再次更改tintColor。
 for window in UIApplication.sharedApplication().windows {
        window.tintColor = UIColor.wrongColor()
    }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接