在UIStatusBar上显示UIWindow后,UIStatusBarStyle发生了更改 [英] UIStatusBarStyle changes after displaying a UIWindow over UIStatusBar

查看:106
本文介绍了在UIStatusBar上显示UIWindow后,UIStatusBarStyle发生了更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 UIStatusBar 上显示UIWindow,默认情况下 UIStatusBarStyle 设置为 UIStatusBarStyleLightContent ,但当我显示 UIWindow 时, UIStatusBarStyle 切换到黑色样式。

I am displaying a UIWindow over the UIStatusBar, by default the UIStatusBarStyle is set to UIStatusBarStyleLightContent, but when I display the UIWindow the UIStatusBarStyle switches to the black style.

推荐答案

我在遇到同样的问题时遇到了这个话题。你要做的是创建一个新的视图控制器并将其设置为 UIWindow 的根视图控制器(即 UIWindow 您正在显示其他视图)。然后,在这个新的视图控制器中实现 preferredStatusBarStyle 方法,如下所示:

I came across this topic while struggling with the same problem. What you have to do is create a new view controller and set it as the root view controller of your UIWindow (that is the UIWindow that you are displaying over your other view). Then, in this new view controller implement the preferredStatusBarStyle method like this:

- (UIStatusBarStyle) preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

或者,您可以设置查看基于控制器的状态栏外观属性在Info.plist中为NO,并按照Azabella的建议实现 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent] 方法。但是,这会将所有视图的状态栏设置为白色。如果这没问题,那么就不需要创建一个单独的视图控制器来设置 preferredStatusBarStyle 方法。

Alternatively, you can set the "View controller-based status bar appearance" property in Info.plist to NO and implement the [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent] method as Azabella suggested. However, this will set the Status Bar of all your views to white. If that's no problem, then there's no need to make a separate view controller just to set the preferredStatusBarStyle method.

这篇关于在UIStatusBar上显示UIWindow后,UIStatusBarStyle发生了更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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