jacobsieradzki jacobsieradzki - 1 year ago 562
Swift Question

setStatusBarHidden(_:withAnimation:) deprecated in iOS 9

I see that in iOS 9

is now deprecated and the documentation says to use
[UIViewController prefersStatusBarHidden]
instead but what is the alternative in iOS 9 if I still want to hide the status bar with a slide animation?

Leo Leo
Answer Source

Refer to preferredStatusBarUpdateAnimation,


enter image description here


class ViewController: UIViewController {
var isHidden:Bool = false
@IBAction func clicked(sender: AnyObject) {
    isHidden = !isHidden
    UIView.animateWithDuration(0.5) { () -> Void in
override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation {
    return UIStatusBarAnimation.Slide
override func prefersStatusBarHidden() -> Bool {
    return isHidden
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download