Search code examples
ioshiddenstatusbar

iOS: hide status bar programmatically, method based NOT viewController based


I am trying to hide/show the status bar in iOS 7 (and 6) programmatically, NOT ViewController based but method based.

For example if i press button 1 the status bar disappears, if i press button 2 the status bar appears.

I have tried all combinations here and from google, but all are viewcontroller based so far.

Does anybody have an idea how to do it, method based?


Solution

  • Use the UIApplication methods

      - (void)setStatusBarHidden:(BOOL)hidden withAnimation:(UIStatusBarAnimation)animation
    

    on the instance [UIApplication sharedApplication]