2

I want to change status bar style when presenting a view controller, and change it back when returning from it, this is my code:

In presented:

override func viewWillAppear(_ animated: Bool) {
    UIApplication.shared.statusBarStyle = .lightContent
}

In presenting:

override func viewWillAppear(_ animated: Bool) {
    UIApplication.shared.statusBarStyle = .default
}

My info.plist:

  • View controller-based status bar appearance = NO
  • Status bar style = default

The animation seemed quite intrusive, am I able to animate the change?

Bright
  • 5,699
  • 2
  • 50
  • 72

1 Answers1

-1

At First you do this: Open your info.plist and insert a new key named "View controller-based status bar appearance" to NO

and change the statusBar colour in whatever viewController.

Like this : UIApplication.sharedApplication().statusBarStyle = .LightContent

If you want to change colour on changing viewController put like this:

override func viewWillDisappear(animated: Bool)

{ super.viewWillDisappear(animated)

UIApplication.sharedApplication().statusBarStyle = UIStatusBarStyle.Default

//this will change the colour when a particular viewController disappear.

}

Sagar Snehi
  • 398
  • 3
  • 13