隐藏状态栏时,我的导航栏会在iOS7中向上移动 [英] When hiding the statusbar my navigation bar moves up in iOS7

查看:685
本文介绍了隐藏状态栏时,我的导航栏会在iOS7中向上移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图隐藏状态栏但保持更大的导航栏高度。现在,当我通过将 - (BOOL)prefersStatusBarHidden 设置为 YES 然后调用 [self setNeedsStatusBarAppearanceUpdate]; 。这个问题是导航栏会向上滑动,不会为我试图显示的通知留出空间。只需在状态栏上添加视图不是一个选项,我们的状态栏/导航具有花哨的模糊效果。有没有人知道如何使用状态栏高度保持标准导航栏高度并从中删除状态栏?

I am trying to hide the statusbar but maintain the "bigger" navigationbar height. Right now when I hide the statusbar by setting - (BOOL)prefersStatusBarHidden to YES and then calling [self setNeedsStatusBarAppearanceUpdate];. The problem with this is that the navigationbar will slide up and won't leave space for the notification I'm trying to show. Simply adding a view over the statusbar is not an option, our statusbar/navigation has the fancy blur effect. Does anyone have a clue how to maintain the standard navigationbar height with the status bar height and remove the statusbar from that?

编辑;我最终做的是冒险并通过私有API获取状态栏的UIWindow并抵消它。

Edit; what I ended up doing is taking a risk and getting the UIWindow of the statusbar via a private API and offsetting that.

编辑2;应用程序已通过私有API批准。但要小心!

Edit 2; App got approved with the private API. Be cautious though!

推荐答案

您可以创建一个自定义UIView,其框架为

You can create a custom UIView with its frame as

customView.frame=CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height);

还可以按照以下步骤隐藏您的状态栏

Also hide your status bar by following the below steps

转到info.plist并添加两个属性(如果不存在)。将状态栏最初隐藏设置为 YES 并将 UIViewControllerBasedStatusBarAppearance 设置为。这会隐藏您应用的状态栏。

Go to info.plist and add two attributes if not present. set "Status bar is initially hidden" to YES and set UIViewControllerBasedStatusBarAppearance to NO. This will hide status bar for your app.

这篇关于隐藏状态栏时,我的导航栏会在iOS7中向上移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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