Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide the status bar with its content on iOS 10 with Swift 3?

I have read this questions, but not only this ones, without finding a solution to my problem:

  • Question 1
  • Question 2
  • Question 3
  • Question 4
  • Question 5
  • Question 6

What it actually happens to me is that I achieve to hide the content of the status bar, but no the status bar itself:

    override var prefersStatusBarHidden: Bool {

        return true

    }

It keeps appearing on the top of the screen, traslucid, with no content at all.

like image 380
Federico Maza Avatar asked Aug 04 '17 16:08

Federico Maza


People also ask

How do I hide status bar on IPAD Swift?

Common Step Go to Your info. plist file. Add a key called “View controller-based status bar appearance” and set its value to NO.

How do I hide my status bar on my Iphone?

You can hide just a few icons or all of them for no status bar at all. To do so, open the Settings app, then scroll down and select "HideStatusBarItems." Once inside, the first thing you'll want to do is enable HideStatusBarItem by putting the toggle next to "Enable Tweak" to the on position.


1 Answers

To hide the status bar programmatically in Swift 3:

UIApplication.shared.keyWindow?.windowLevel = UIWindowLevelStatusBar

To bring it back:

UIApplication.shared.keyWindow?.windowLevel = UIWindowLevelNormal 

If you want you can learn more about UIWindowLevel in Apple's docs.

like image 63
Alexandre Lara Avatar answered Oct 20 '22 00:10

Alexandre Lara