Check whether status bar is hidden or visible

Prajan picture Prajan · Aug 16, 2011 · Viewed 15.7k times · Source

I want to check condition for statusbar. How can i check condition if status bar is visible or not .

please anyone guide me to do this..

Thank you all

Answer

Mobile Developer picture Mobile Developer · Aug 16, 2011

Check if status bar is hidden:

Objective C:

if ([UIApplication sharedApplication].isStatusBarHidden) {
    // do stuff here...
}

Swift:

if UIApplication.shared.isStatusBarHidden {
    // do stuff here...
}

Hide status bar:

override var prefersStatusBarHidden: Bool {
    return true
}