Search code examples
iosios7statusbar

Toggle ios7 status bar


I would like to know if there is a way to hide the ios7 status bar temporarily (i.e toggle). I have scoured the internet and I can only find out how to turn it off indefinitely.

The thing being is I have one subview that I use as a full screen and unfortunately the status bar needs to be hidden in order to make the subview look cleaner.

This is the code I have found to hide the status bar.. but i have no idea how to bring it back again after hiding it.

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

any help would be greatly appreciated.


Solution

  • It is actually right in the description of the method in the documentation here

    If you change the return value for this method, call the setNeedsStatusBarAppearanceUpdate method.

    So just make your prefersStatusBarHidden method return YES or NO conditionally based on whether you want it hidden or not and call setsNeedsStatusBarAppearanceUpdate when you know the result will change.

    example:

    - (BOOL)prefersStatusBarHidden
    {
        if(someViewIsVisible)
            return YES;
        else
            return NO;
    }