1

I embeded in a navigation controller to a viewController, and a nav bar item is showing (in the outline editor), and I can change the title, but the navigation bar is not showing in the (outline editor) and I therefore cannot change the bar tint color. So I tried adding in a nav bar programmatically, like this:

.h file

@property (strong, nonatomic) UINavigationBar *nav;

.m file

nav = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
self.nav.tintColor = [UIColor blueColor];
[self.view addSubview:nav];

And here is the outcome:

enter image description here

Update

enter image description here

4

3 回答 3

2

您在上面回答中的最后一条评论“我将颜色设为蓝色,并在情节提要中显示为蓝色”在这里是冲突的。

我猜您无法为导航栏设置色调。因为 Storyboard 不会为导航栏显示任何颜色色调颜色,所以它仅在运行时可见(在模拟器中)。

即使您更改导航栏的色调颜色,它仍然显示为白色。

我们来看一下:

  1. 正如“matt”所说:您必须更改UINavigationController作为应用程序起点的条形色调颜色。选择作为初始根视图控制器的导航控制器。

在此处输入图像描述

  1. 从突出显示的Navigation Controller下方的左侧区域中选择Navigation Bar。在属性检查器中,您可以看到导航栏的属性。在本节中,您可以看到现在显示 Default 的Bar Tint 。

在此处输入图像描述

  1. 根据需要从属性更改Bar Tint颜色。注意这里的变化在 Storyboard 中不可见,Bar 颜色将在 Storyboard 中保持白色,仅在模拟器/设备中可见。

在此处输入图像描述

  1. 查看模拟器中的输出。

在此处输入图像描述

于 2014-12-23T07:43:00.597 回答
1

不要那样做。删除该代码。导航控制器已经有了导航栏;不要添加另一个。

你看错了场景。有一个导航控制器场景和一个视图控制器场景。导航栏属于导航控制器场景。

在此处输入图像描述

于 2014-12-22T20:10:17.123 回答
0

我使用的是对 ipad 和 iphone 灵活的 viewController。现在在那个 viewController 中,我为每个 viewController 插入了一个导航控制器。(令人惊讶的是,xcode 允许您这样做。当时我不知道这是错误的。)所以我在导航控制器上设置了条形颜色,这不是第一个。(它是第二个视图导航控制器)因此它有一个冲突,即采用哪种颜色,来自第一个导航控制器的颜色,或当前导航控制器。

于 2014-12-23T18:41:22.840 回答