【问题标题】:Changing the NavigationBar chevron and title color has no effect更改 NavigationBar 人字形和标题颜色无效
【发布时间】:2016-06-05 15:38:34
【问题描述】:

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

我的应用从导航控制器开始。

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

- (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在“

难道这些不应该尊重导航栏类上使这些项目变为白色的设置吗?

怎么了?

【问题讨论】:

  • 试试 [self.appearance setTintColor:[UIColor yourcolor]];
  • 没有self.appearance api。

标签: ios iphone uinavigationcontroller uinavigationbar


【解决方案1】:

要全局设置该颜色,您可以在 AppDelegate 中使用类似的内容:

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

或者在 Swift 中:

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

【讨论】:

  • 我试过了。人字形会改变颜色,但不会改变后退按钮文本的颜色。
  • 奇怪,我一直用这个。在您最初的问题中,这句话中的最后一个词应该是“黑色”吗? “那个按钮和人字形都回来了。”如果是这样 - 看起来您正在其他地方覆盖全局和本地设置。
  • 没有。该课程使项目变为白色,这就是我想要的,但它们是黑色的。
  • 我曾经遇到过一个问题,我不小心将视图的 alpha 设置为 0 并忘记了它,因为它在 iPad 上看起来很好。你检查了吗?
  • 发现了问题。像这样的第二组指令被遗忘在代码的另一部分。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多