如何使 UINavigationController 的 UINavigationBar 不可见或至少改变颜色 [英] How can I make a UINavigationController's UINavigationBar invisible or at least change color

查看:26
本文介绍了如何使 UINavigationController 的 UINavigationBar 不可见或至少改变颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UINavigationController,它链接到一个设置为 RootController 的 ViewController.我启用了 UINavigationBar 并在其中放置了 3 个 UIViews,每个 UIViews 都有一个 UIButton.理想情况下,我想让 UINavigationBar 完全不可见,但我也愿意将颜色设置为我的 ViewController 的背景颜色.我正在快速工作,我尝试过诸如

I have a UINavigationController that is Linked to a ViewController that is set as RootController. I have enabled the UINavigationBar and put 3 UIViews each with a UIButton inside. Ideally I would like to make the UINavigationBar completely invisible, but I would also settle for setting the color to the background color of my ViewController. I am working in swift and I have tried things like

self.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
self.navigationBar.shadowImage = UIImage()
self.navigationBar.translucent = true

但是没有任何变化.有没有正确的方法来做到这一点?

However nothing changes. Is there a correct way to do this?

推荐答案

在 swift 中,您可以:

In swift, you can do:

self.navigationController?.setNavigationBarHidden(true, animated: true)

请参考文档 了解更多详情.

Please refer to Documentation for more details.

这篇关于如何使 UINavigationController 的 UINavigationBar 不可见或至少改变颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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