Gehlen
Gehlen

Reputation: 160

StatusBar ins't calling preferredStatusBarStyle when setting View controller-based status bar appearance = YES

The title says it all. Or have something VERY wrong whit me to understand the sdk, or something is VERY wrong with apple's sdk.

When setting (info.plist) View controller-based status.. = YES, I can hide my statusbar animated and whatever, by calling setNeedsStatusBarEtc... But then, I cant change my preferredStatusBarStyle. And When I set it to NO, I can change the style, but not everything else.. What do I do? What's is wrong? Please, some help!

When controller-based status.. = YES

So in my ViewController I create a statusBarHidden: Bool and override class var: prefersStatusBarHidden: Bool, preferredStatusBarUpdateAnimation: Bool and preferredStatusBarStyle to change my statusBar.

var statusBarHidden = false {
    didSet {
        UIView.animate(withDuration: 0.3) { () -> Void in
            self.setNeedsStatusBarAppearanceUpdate()
        }
    }
}

But then, this code will call prefersStatusBarHidden and preferredStatusBarUpdateAnimation only, but not preferredStatusBarStyle. Whit controller-based status.. = NO, it is called, but the others isn't. I just want a lightContent StatusBar hiding in some VCs..

A deprecated solution:

 UIApplication.shared.isStatusBarHidden = true

But can't animate (at least I couldn't)

Thanks to @WillBoland

Upvotes: 4

Views: 693

Answers (1)

Will Boland
Will Boland

Reputation: 144

As Per this link, using the following worked.

[[UIApplication sharedApplication] setStatusBarHidden:NO]

It is deprecated though.

Upvotes: 0

Related Questions