Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIStatusBarStyle changes after displaying a UIWindow over UIStatusBar

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.

like image 538
David Gölzhäuser Avatar asked Oct 27 '13 10:10

David Gölzhäuser


3 Answers

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;
}

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.

like image 165
Tuslareb Avatar answered Nov 09 '22 21:11

Tuslareb


Did you set the "View controller-based status bar appearance" property in yourAppName-Info.plist to NO ?

like image 40
user2006934 Avatar answered Nov 09 '22 21:11

user2006934


This was a fairly trivial problem that I found to be resolved setting modalPresentationCapturesStatusBarAppearance to true.

like image 1
jsetting32 Avatar answered Nov 09 '22 21:11

jsetting32