john afordis
john afordis

Reputation: 317

Xcode 8.2: Swift3- how to hide status bar?

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

Upvotes: 6

Views: 7600

Answers (3)

Museer Ahamad Ansari
Museer Ahamad Ansari

Reputation: 5523

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

Upvotes: 14

Suhit Patil
Suhit Patil

Reputation: 12023

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

Upvotes: 1

KAR
KAR

Reputation: 3361

In swift 3 use this,

override var prefersStatusBarHidden: Bool {  
    return true  
}

Reference link

Upvotes: 1

Related Questions