更改 NavigationBar 人字形和标题颜色无效

Changing the NavigationBar chevron and title color has no effect

我正在尝试设置导航栏后退按钮的颜色和后退按钮的 V 形。

我的应用程序以导航控制器开始。

此导航控制器有一个自定义 class,其中包含以下几行:

- (void)awakeFromNib {
  [super awakeFromNib];

  UIColor *white = [UIColor whiteColor];
  [self setTintColor: white];
//  [self setBarTintColor: white];

  UIFont *fonte = [UIFont fontWithName:@"Avenir-Book" size:14.0f];
  NSDictionary *atributos =  @{NSForegroundColorAttributeName : white,
                               NSFontAttributeName : fonte
                               };

  [self setTitleTextAttributes:atributos];

}

该导航控制器的根视图控制器隐藏了导航栏。这个根视图控制器称为主屏幕。

我从那个视图控制器推送另一个导航栏可见的视图控制器。该导航栏没有我添加的后退按钮,但 iOS 在“<主屏幕”处放置了一个后退按钮和一个人字形。那个按钮和人字形都回来了。

这些不是应该尊重导航栏上的设置 class 使这些项目变白吗?

怎么了?

要全局设置该颜色,您可以在 AppDelegate 中使用类似这样的东西:

UINavigationBar *navBarAppearance = [UINavigationBar appearance];
[navBarAppearance setTintColor:[UIColor greenColor]];

或在Swift中:

let navBarAppearace = UINavigationBar.appearance()
navBarAppearace.tintColor = UIColor.greenColor()