1

If I want to hide the status bar of a single view controller subclass then I do this:

override var prefersStatusBarHidden: Bool {
    return true
}

But what if I want to hide status bar by default in all view controllers subclass or not? Checking "Hide status bar" in the project settings does nothing.

I'm trying to program UIPageViewController which contains many view controllers attached to it. It would be nice not having to subclass them all.

Kawin P.
  • 187
  • 1
  • 11

2 Answers2

5

Go to your Info.plist file and add a new attribute:

View Controller based status bar appearance and set it to NO.

enter image description here

Then go to App Delegate and replace your method to this:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        UIApplication.shared.isStatusBarHidden = true
        return true
    }
Mr. Xcoder
  • 4,719
  • 5
  • 26
  • 44
1

right click your Info.plist and select Open As > Source code

at the end of the file, before

</dict>
</plist>

add this

<key>UIStatusBarHidden</key>
<true/>

or add Status bar is initially hidden and set it to YES

Mentos
  • 483
  • 1
  • 4
  • 14