【问题标题】:Changing custom UINavigationBar attributes not working completely swift更改自定义 UINavigationBar 属性不能完全迅速
【发布时间】:2019-11-08 08:55:58
【问题描述】:

我正在更改自定义navigationBar 的默认导航栏,以设置自定义本地化标题,但我无法像往常一样更改它的标题颜色和后退按钮。你能看出我做错了什么吗? 像往常一样非常感谢

navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationBar.shadowImage = UIImage()
navigationBar.backgroundColor = .clear
navigationBar.backItem?.leftBarButtonItem?.tintColor =  Theme.secondTintColor // not working
navigationItem.title = NSLocalizedString("Route Checkings VC Title", comment: "")
navigationItem.titleView?.tintColor = Theme.secondTintColor // not working
navigationItem.rightBarButtonItem?.tintColor = Theme.firstTintColor
navigationItem.leftBarButtonItem?.tintColor = Theme.secondTintColor // not working

【问题讨论】:

  • 你需要更改navigationBar.barTintColornavigationBar.tintColor

标签: ios swift uinavigationbar uinavigationitem


【解决方案1】:

试试这个

    navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
    navigationController?.navigationBar.tintColor = UIColor.white

【讨论】:

  • 首先欢迎来到这个伟大的社区。第二,谢谢。我之前确实尝试过,但我一定是打错了。它现在按预期工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-02-05
  • 1970-01-01
  • 2021-09-18
  • 1970-01-01
  • 1970-01-01
  • 2021-08-02
  • 2013-06-22
相关资源
最近更新 更多