导航栏未显示在情节提要中 [英] Navigation Bar not showing in Storyboard

查看:126
本文介绍了导航栏未显示在情节提要中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将导航控制器嵌入到viewController中,并且显示了导航栏项目(在大纲编辑器中),并且可以更改标题,但是导航未显示在导航栏中(概述编辑器),因此我无法更改条形颜色.因此,我尝试以编程方式添加导航栏,如下所示:

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

这是结果:

更新

推荐答案

您在上述最后的评论中回答我将颜色设置为蓝色,并且在情节提要中显示为蓝色" 在这里.

Your last comment in above answer that "I made the color to blue, and it shows it blue in the storyboard" is conflict here.

我想您无法为导航栏设置色调颜色.由于情节提要板不会在导航栏上显示任何颜色,因此仅在运行时可见(在Simulator中).

I guess you are not able to set tint color for navigation bar. Because Storyboard won't show any color tint color for navigation bar, it's only visible at run time (In Simulator).

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

Even if you change tint color of navigation bar it still shows white color.

让我们看看:

  1. 正如亚光"所说:您必须更改UINavigationController的条形色彩,这是应用程序的起点.选择导航控制器,它是初始的根视图控制器.
  1. As "matt" said : You have to change bar tint color of UINavigationController which is starting point of your application. Select navigation controller which is initial root view controller.

  1. 从突出显示的导航控制器下方的左侧区域中选择导航栏.在属性检查器中,您可以查看导航栏的属性.在此部分中,您可以看到 Bar Tint (条形图着色),该列现在显示默认".
  1. Select Navigation Bar from left area below the highlighted Navigation Controller. In Attribute Inspector you can see properties for navigation bar. In this section you can see Bar Tint which shows Default right now.

  1. 根据需要从属性中更改酒吧色调的颜色.观察到这里的变化不会在情节提要中可见,条形颜色将保持为白色,而在情节提要中颜色将仅在模拟器/设备中可见.
  1. Change Bar Tint color from properties as your need. Observation here is changes will not be visible in Storyboard, Bar color will remains white in Storyboard color will only visible in Simulator/Device.

  1. 在Simulator中查看输出.

这篇关于导航栏未显示在情节提要中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆