使用纯色背景使导航栏不透明

Make Navigation Bar Opaque with solid bg color

我正在尝试为导航栏设置纯色,但它总是显示为半透明。

None 我试过的 SO 答案似乎有效。

我试过:

在 App Delegate 中:

[[UINavigationBar appearance] setBackgroundColor:[UIColor colorWithRed:89/255.0 green:196/255.0 blue:197/255.0 alpha:1.0f]];

在我的主 TableviewController 中:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:89/255.0 green:196/255.0 blue:197/255.0 alpha:1.0f];

    self.navigationController.navigationBar.translucent = NO;

}

我还取消选中了 Translucent 选项并选中了属性检查器中的 Opaque 选项。

以下是我想要实现的目标的图像:

如何使导航栏不透明且具有纯色背景?

谢谢。

转到导航栏的属性检查器并从半透明中删除复选标记。

请在图中查找。

我也在想办法让导航栏背景变成纯色。我试图从 Storyboard - Attribute inspector 更改背景颜色,但这是错误的选择。

属性检查器中的Bar Tint颜色改变了导航控制器的背景颜色。