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

查看:192
本文介绍了在状态栏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个空间保留,但状态栏内容会在横幅之后消失滑回来。有没有办法做到这一点或在状态栏上方添加子视图或窗口?

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天全站免登陆