Search code examples
iphonestatusbar

Check whether status bar is hidden or visible


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


Solution

  • 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
    }