How to hide status bar of a single view controller in iOS 9?

ios hide status bar programmatically
hide status bar ios 13
hide status bar ios 12
view controller-based status bar appearance
preferredstatusbarstyle not called
ios status bar color
prefersstatusbarhidden not working ios 13
status bar hide ios swift

In a ViewController, which I presented modally, I did this:

override func prefersStatusBarHidden() -> Bool {
    return true
}

This used to work, but it no longer works. What's the best way to hide the status bar only for this view controller?

For Swift 3 & Swift 4 it has changed to overriding a variable like this:

override var prefersStatusBarHidden: Bool {
  return true
}

If you want to "Update" the state once the view controller is already being displayed, you will need to call:

setNeedsStatusBarAppearanceUpdate()

Please refer to the documentation.

How to hide status bar of a single view controller in iOS 9 , In a ViewController, which I presented modally, I did this: override func prefersStatusBarHidden() -> Bool { return true }. This used to work, but it  In a split view, a navigation bar may appear in a single pane of the split view. Navigation bars are translucent, may have a background tint, and can be configured to hide when the keyboard is onscreen, a gesture occurs, or a view resizes.

For Swift 3 and Swift 4.2 when view going to Appear

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    UIApplication.shared.isStatusBarHidden = true
}

when view goint to Dissapear

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)

    UIApplication.shared.isStatusBarHidden = false
}

It's possible you need set in your info.plist, next line:

View controller-based status bar appearance = NO

How to hide the status bar, Any view controller containing that code will hide the status bar by default. If you want to animate the status bar in or out, just call setNeedsStatusBarAppearanceUpdate() on your view controller – that will force prefersStatusBarHidden to be read again, at which point you can return a different value. The difference between this answer and the other answers on here is that in my info.plist when I initially had View controller-based status bar appearance - NO with the 2 statusBar methods below it didn't work but when I changed it to Yes is worked with both of them. In the info.plist change: View controller-based status bar appearance - YES

In your UIViewController:

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    UIApplication.shared.isStatusBarHidden = true
}

 override func viewWillDisappear(_ animated: Bool) {
    super.viewWillDisappear(animated)
    //It will show the status bar again after dismiss
    UIApplication.shared.isStatusBarHidden = false
}

override var prefersStatusBarHidden: Bool {
    return true
}

The Mysterious Case of the Status Bar - craiggrummitt, So if you hunt around, there are several ways to manipulate the status bar, let's Light(i.e. light text) or Default(i.e. dark text); Hide status bar — a checkbox. View controller-based status bar appearance — I'll come back to this one in a moment. isStatusBarHidden and statusBarStyle properties were deprecated in iOS 9. The style of the status bar can be changed to a status bar with white content. Go to the ViewController.swift file and add the following lines of code. The preferredStatusBarStyle property is set to lightContent. Build and Run the project to see the content of the status bar changed to light.

In iOS 9, Xcode 7, Swift 2.0, it's back to how it was previously.

override func prefersStatusBarHidden() -> Bool {
        return true
}

In fact Xcode will tell you that

UIApplication.sharedApplication().setStatusBarHidden(true, withAnimation: .None) 

has been deprecated and that you should use the prefersStatusBarHidden method.

hide status bar iOS 11 Swift 4 don't work |Apple Developer Forums, I am trying to hide status bar in one of my UIViewControllers (Swift 4). Firstly, I set View controller-based status bar appearance to YES in  xcode hide status bar (4) . Say a user is in a View Controller and wants to enter a "full screen" type mode where the status bar is hidden, under iOS 6 it was a simple method call to hide/show the status bar, but no matter what it seems to persist under iOS 7.

For Swift 3,

override var prefersStatusBarHidden: Bool{
        return true
    }

and add viewDidLoad()

self.modalPresentationCapturesStatusBarAppearance = true

Show/Hide status bar in only one ViewController, objective C, iOS, Show/Hide status bar in only one ViewController, objective C, iOS - ios. setStatusBarHidden:YES withAnimation:NO]; but it is deprecated in iOS 9.0 I am using  Hi I'd like to hide Status bar on iOS 7.0 this code is not working: UIApplication.SharedApplication.SetStatusBarHidden (false, true); Regards Koto This site uses cookies for analytics, personalized content and ads.

How To Hide The Status Bar In Xcode 10 (Swift 4.2), hide status bar view controller swift, hide status bar swift hide status bar on one view Duration: 3:01 Posted: Dec 30, 2018 How to hide the status bar in iOS 7 using Xamarin Forms. In order to hide the status bar, one has to add 2 properties in the Info.plist file. Edit the file and switch to Source view. Add an entry named UIStatusBarHidden and set the value to true. Add an entry named UIViewControllerBasedStatusBarAppearance and set the value to false.

Xcode hide status bar, #iOS 11 Xcode 9 Navigation bar height not changes and also status bar is not hidden getting 20 px How to hide status bar of a single view controller in iOS 9​?

Change the Color of the Status Bar iOS Tutorial, The status bar can have a dark and light appearance inside an app In this tutorial the appearance of Open Xcode and create a new Single View App. Go to the ViewController.swift file and add the following lines of code.

Comments
  • just check Programtically way this
  • It's still working fine. If you want to apply the function to all of your View Controllers then consider using inheritance.
  • Possible duplicate of How to hide a status bar in iOS?
  • Just go to info.plist and update View controller-based status bar appearance to YES as mentioned by @lance
  • in tabbarcontroller setNeedsStatusBarAppearanceUpdate() not make prefersStatusBarHidden triggered
  • @famfamfam Make sure you don't have controller-based status bar appearance disabled in your info.plist. If you do this property is completely ignored. Also, PrefersStatusBarHidden might be getting called in a parent controller instead. It depends on how you organized your view controllers.
  • This is the only answer that worked fine in my case, perfect!
  • I believe it works since you messed up the ViewController hierarchy and system don't call for prefersStatusBarHidden.
  • This is the only way I could do it but I also had to add <key>UIViewControllerBasedStatusBarAppearance</key> <false/> to my info.plist file
  • I just used it and it worked perfect! Thanks for that
  • If the prefersStatusBarHidden method does nothing, add setNeedsStatusBarAppearanceUpdate() to your viewDidLoad or viewDidAppear method. Depending on what you want to achieve.
  • The best answer
  • Thank you very much for your precious answer
  • You can skip code written in viewDidLoad(). setting flag in info.plist and overriding prefersStatusBarHidden is enough. Nice work bro, thanks for the help