在 iOS 7 状态栏上方添加 UIView 横幅 [英] Add UIView banner above status bar iOS 7

查看:10
本文介绍了在 iOS 7 状态栏上方添加 UIView 横幅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在收到应用内推送通知时在状态栏上方添加横幅.从我读过的内容来看,似乎在 iOS 7 中动态更改状态栏样式的唯一方法是将 UIViewControllerBasedStatusBarAppearance 设置为 NO.这不仅真的很烦人,必须将我所有不同的视图控制器 prefersStatusBarHidden 更改为 [UIApplication sharedApplication].statusBarHidden,而且它也没有给出我想要的效果寻找.

I'm trying to add a banner above the status bar when receiving an in-app push notification. From what I've been reading, it seems like the only way to dynamically change the status bar style in iOS 7 is to set UIViewControllerBasedStatusBarAppearance to NO. This is not only really annoying to have to change all my different view controllers prefersStatusBarHidden to [UIApplication sharedApplication].statusBarHidden, but it also doesn't give the effect I'm looking for.

当横幅从顶部滑动时,我仍然希望状态栏提供的 20 pts 空间保留,但状态栏内容会消失,直到横幅滑动回来.有没有办法做到这一点或在状态栏上方添加子视图或窗口?

When the banner slides from the top, I still want the 20 pts of space that the status bar provides to stay, but the status bar content to disappear until after the banner slides back up. Is there a way to either do this or add a subview or window above the status bar?

基本上我希望这样做:

推荐答案

创建一个新窗口并将您的横幅视图添加到该窗口.当您需要显示横幅时,您可以设置 yourwindow.hidden = NO; 您可以进一步添加动画来显示和关闭它yourwindow.hidden = YES;.

Create a new window and add your banner view to that window. When you need to show the banner, you can set yourwindow.hidden = NO; You can further add animations to showing it and to dismiss it yourwindow.hidden = YES;.

这里的关键是设置yourwindow.windowLevel = UIWindowLevelStatusBar+1;

这将确保您的横幅视图和 yourwindow 始终显示在状态栏上方.

That will make sure your banner view and the yourwindow always appear above the status bar.

请随时提出有关上述任何问题的问题.

Feel free to ask questions regarding any of the above.

这篇关于在 iOS 7 状态栏上方添加 UIView 横幅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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