iOS - UINavigationController,隐藏navigationBar [英] iOS - UINavigationController, Hide navigationBar

查看:314
本文介绍了iOS - UINavigationController,隐藏navigationBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在为UINavigationController隐藏navigationBar时遇到了一些小麻烦

I have a minor trouble hiding the navigationBar for my UINavigationController

我添加了:

self.navigation!.navigationBar.hidden = true

这很遗憾某种背景(白色)留在白色状态栏后面向下推内容(绿色),以及不需要的滚动行为,我可以上下拖动内容来显示/隐藏白色背景。我需要的是状态栏不占用任何垂直空间,而是放在内容之上(绿色)

This, unfortunately leaves some kind of background (white) left behind the white status bar that pushes the content (green) downwards, and an unwanted scroll behaviour where I can drag the content up and down to show/hide the white background. What I need is for the statusbar to take up no vertical space what so ever and lay on top of the content (green)

我如何实现这一目标?
非常欢迎swift和obj-c中的答案

How do I achieve this? Answers in swift as well obj-c are very welcome


编辑:
我尝试了以下各种版本,问题仍然存在 - .-

I have tried various versions of the following, the problem remains -.-

override func loadView() {
    self.view = UIView(frame:UIScreen.mainScreen().bounds)
    self.view.backgroundColor = UIColor.whiteColor()


    self.navigation = UINavigationController(rootViewController: self.guideViewController!)

    self.navigation!.navigationBarHidden = true
    self.navigation!.setNavigationBarHidden(true, animated: true)

    self.view.addSubview(self.navigation!.view)
}

override func viewDidLoad() {
    self.automaticallyAdjustsScrollViewInsets = false
    self.navigation!.automaticallyAdjustsScrollViewInsets = false
}

编辑2:

prin ting:

printing:

UIApplication.sharedApplication().statusBarFrame.size.height

在viewDidLoad返回20之后

after viewDidLoad returns 20

推荐答案

更新:

只需在此添加 ViewDidLoad 方法

self.automaticallyAdjustsScrollViewInsets = NO;

这篇关于iOS - UINavigationController,隐藏navigationBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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