6

all trying to hide status bar with Xcode 8.2 with swift 3. but I can't hide it.

enter image description here

enter image description here

and also for,

enter image description here

rmaddy
  • 314,917
  • 42
  • 532
  • 579
john afordis
  • 317
  • 3
  • 15

3 Answers3

14

You can Approach this in two ways

Option 1.Try this in didFinishLaunchingWithOptions Method

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    UIApplication.shared.isStatusBarHidden = true

    return true
}

Option 2. overrideprefersStatusBarHidden function in your UIViewController

override var prefersStatusBarHidden : Bool {
    return true
}

Note: you call override func prefersStatusBarHidden it should be override var prefersStatusBarHidden

Museer Ahamad Ansari
  • 5,414
  • 3
  • 39
  • 45
1

In swift 3 use this,

override var prefersStatusBarHidden: Bool {  
    return true  
}

Reference link

Community
  • 1
  • 1
KAR
  • 3,303
  • 3
  • 27
  • 50
1

override prefersStatusBarHidden in your view controller

override var prefersStatusBarHidden : Bool {
        return true
    }

true if the status bar should be hidden or false if it should be shown.

Refer apple doc link

Suhit Patil
  • 11,748
  • 3
  • 50
  • 60