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

标签 ios iphone uinavigationcontroller uinavigationbar

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

我的应用以导航 Controller 开始。

这个导航 Controller 有一个带有这些行的自定义类:

- (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];

}

该导航 Controller 的 Root View Controller 隐藏了导航栏。这个 Root View Controller 称为主屏幕。

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

难道这些不是应该遵守使这些项目变白的导航栏类上的设置吗?

怎么了?

最佳答案

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

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

或者在 Swift 中:

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

关于ios - 更改 NavigationBar 人字形和标题颜色无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37643680/

相关文章:

ios - 如何以编程方式对 UILabel 应用约束,使其位于 Objective C 中 View 底部上方 20px

iphone - 带有底部工具栏的 UI 导航 Controller 在 View 切换时丢失 UIBarButtonItem

ios - 无法创建 PDF 和打印超过 60 页(内存升高和崩溃)

iphone - iPhone 上的访问崩溃日志数据

javascript - 如何更改 iOS 网站的视口(viewport)?

iOS - 使按钮在静态 View 中旋转,如相机应用程序

iphone - 当前位于 UINavigationContoller 的 viewController 堆栈中的 UIViewController 是否会被卸载?

ios - 导航 Controller 和容器 View 之间的通信

ios - 如何读回用 NSKeyedArchiver 保存的 xml 文件?

ios - 如何在 UITableview iOS 的每一行添加多个按钮和标签