0

How to hide, show or change the status bar dynamically on events such as click or value change?

I've googled for a well, but all I get is changed from the beginning as this. Here I need to do it dynamically.

Community
  • 1
  • 1
LF00
  • 27,015
  • 29
  • 156
  • 295
  • For manually config the status bar, refer to this [post](http://stackoverflow.com/q/38876249/6521116). – LF00 May 15 '17 at 08:28

3 Answers3

1

Well for this you can do following based on events:

//For hiding/unhiding:
    func hideStatusBar(shouldHide:Bool){
     UIApplication.shared.isStatusBarHidden = shouldHide
    }

    //For Light Style:
    func lightStatusBar(){
        UIApplication.shared.statusBarStyle = .lightContent
    }

    //For Standard Style:
    func standardStatusBar(){
        UIApplication.shared.statusBarStyle = .default

    }

or you can tweak prefersStatusBarHidden: as well.

ankit
  • 3,537
  • 1
  • 16
  • 32
1

UIApplication.sharedApplication().setStatusBarHidden=true

1

You are looking for var prefersStatusBarHidden: Bool { get }

Override that function in your view controller. Dynamically update the visibility of your statusbar with func setNeedsStatusBarAppearanceUpdate()

https://developer.apple.com/reference/uikit/uiviewcontroller/1621440-prefersstatusbarhidden

Daniel
  • 1,473
  • 3
  • 33
  • 63