【问题标题】:self.view.background color is overridding uinavigationbar colorself.view.background 颜色覆盖导航栏颜色
【发布时间】:2017-06-02 06:46:14
【问题描述】:

我正在尝试为整个视图设置背景颜色和导航栏背景颜色

self.view.backgroundColor = [UIColor someColor];
self.navigationController.navigationBar.barTintColor = [UIColor redColor];

但导航栏颜色没有以红色显示。为什么会这样?任何帮助将不胜感激。

我希望导航栏背景为红色,除了所有视图都应为灰色,包括状态栏。

【问题讨论】:

  • 请贴出你的故事板截图和模拟器输出的截图
  • 您在 viewdidload 中添加代码的位置,否则
  • 我在 viewDidLoad 中添加它
  • 你想在整个应用程序中应用相同的颜色还是为了特定的视图?
  • @Sivagami - 添加 viewdidappear 并尝试一次

标签: ios objective-c uinavigationbar


【解决方案1】:

您是否将 isTranslucent 标志设置为 false?

self.navigationBar?.tintColor = UIColor.white
self.navigationController.navigationBar?.barTintColor = SOMECOLOR
self.navigationController.navigationBar?.isTranslucent = false
self.view.backgroundColor = SOMECOLOR

【讨论】:

    【解决方案2】:

    1.点击导航控制器

    2.现在打开故事板左侧的Show Document Outline。

    3.点击导航栏。

    You can show image here

    4.现在继续Attributes Inspector,现在您可以直接从Bar Tint设置导航栏颜色。您也可以更改Title字体和Title Color。

    You can show image here 2

    【讨论】:

      猜你喜欢
      • 2020-07-09
      • 2015-07-22
      • 1970-01-01
      • 1970-01-01
      • 2020-04-29
      • 1970-01-01
      • 2016-05-04
      • 1970-01-01
      • 2020-11-28
      相关资源
      最近更新 更多