4

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

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Gehlen
  • 160
  • 1
  • 15
  • post your code, please. – JAB Jan 20 '17 at 02:07
  • @BJHStudios updated! – Gehlen Jan 20 '17 at 03:56
  • @Gehlen , more code ,please. It is difficult to understand you. 'l prefersStatusBarHidden and preferredStatusBarUpdateAnimation' - where do you use this? 'Whit NO, it is called.' - what does it mean? Make your post more clear, please. – Vyacheslav Jan 20 '17 at 11:54
  • @Vyacheslav updated! – Gehlen Jan 20 '17 at 12:21
  • check this link http://stackoverflow.com/questions/41670828/xcode-hide-white-status-bar-ios-10/41671143#41671143 – Birendra Jan 20 '17 at 12:28
  • Look at this discussion: http://chat.stackoverflow.com/rooms/133245/discussion-between-birendra-and-ossir – Will Boland Jan 20 '17 at 15:24
  • @WillBoland thanks for that. Looks like this deprecated method is working: [[UIApplication sharedApplication] setStatusBarHidden:NO] But I'll wait for non deprecated solution.. (I didn't tried this yet); If it works with swift I'll update with solution suggestion. Thank you! – Gehlen Jan 20 '17 at 18:47
  • No problem. Even though it is in Objective-C, still works. Hopefully there will be a non-depracated solution. – Will Boland Jan 20 '17 at 22:16
  • I don't understand the question. – Sulthan Jan 20 '17 at 23:41
  • @Sulthan need more context? What is your doubt? Essentially, what I want is hide/show status bar animated and change its style. But looks like you can't do both things.. Maybe its a semantic error with the sdk? Until now, I couldn't find any solution that isn't deprecated (and even with deprecated solution - I can't animate the hide action)... Any idea? – Gehlen Jan 21 '17 at 14:37

1 Answers1

0

As Per this link, using the following worked.

[[UIApplication sharedApplication] setStatusBarHidden:NO]

It is deprecated though.

Community
  • 1
  • 1
Will Boland
  • 146
  • 2
  • 13