删除使用故事板创建的导航栏中的半透明栏 [英] remove translucent bar in navigation bar created with storyboard

查看:66
本文介绍了删除使用故事板创建的导航栏中的半透明栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从故事板创建了一个navigationController,现在我正在尝试删除它的半透明选项

I created a navigationController from the storyboard and now i'm trying to remove it's translucent option

我把它放在我的appdelegate.m上

I've put this on my appdelegate.m

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:52.0/255 green:152.0/255 blue:219.0/255 alpha:1]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];

[[UINavigationBar appearance] setTranslucent:NO];

但这会导致我的应用程序出现无意义错误,所以我不确定这是不是正确的方法。

But this is crashing my app with a nonsense error, so I'm not sure if this is the right approach.

我发现了类似的问题,但没有解决我的问题:
导航控制器透明栏样式无效

I have found this similar question but didn't solved my problem: Navigation Controller Transparent Bar Style is not working

但是我我不知道该怎么做因为我没有变量navController,因为我从故事板创建了我的navigationController。如何以编程方式调用故事板导航控制器并执行类似的操作?

But I'm not sure how to do that because I don't have a variable navController since I created my navigationController from the storyboard. How can I call the storyboard navigation controller programmatically and do something like that?

谢谢

推荐答案

在导航堆栈上出现的第一个视图控制器上将其添加到 viewDidLoad

Add this to viewDidLoad on the first view controller appearing on the navigation stack:

self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

这篇关于删除使用故事板创建的导航栏中的半透明栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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