IOS: hide the status bar of the entire application programmatically not even through plist

I want to hide the status bar in my entire application.

Also, I also know this, that we can do it as follows:

set the key value "View controller-based status bar appearance" NO in plist.

But I need to do the same only for iOS 7, so, of course, for the OS version some condition is required, and as far as I know, we cannot apply any condition in the .plist file.

Therefore, please offer some line of code that only hides the status bar for iOS 7.

Rate your answer.

+4
source share
3 answers
//Checking iOS version
 float versionOS;
 versionOS=[[[UIDevice currentDevice] systemVersion] floatValue];
  if(versionOS>=7.0)
   {
         [UIApplication sharedApplication].statusBarHidden = YES
   }  

Add this code to the method application didFinishLaunchingWithOptions.

+5
source

:

- (BOOL)prefersStatusBarHidden {
    return YES;
}

ios 7, ios7.

+5

The easiest method I found to hide the status bar throughout the application is to create a category on the UIViewController and override prefersStatusBarHidden. Thus, you do not need to write this method in each individual view controller.

UIViewController + HideStatusBar.h

#import <UIKit/UIKit.h>

@interface UIViewController (HideStatusBar)

@end

UIViewController + HideStatusBar.m

#import "UIViewController+HideStatusBar.h"

@implementation UIViewController (HideStatusBar)

//Pragma Marks suppress compiler warning in LLVM. 
//Technically, you shouldn't override methods by using a category, 
//but I feel that in this case it won't hurt so long as you truly 
//want every view controller to hide the status bar. 
//Other opinions on this are definitely welcome

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"

- (BOOL)prefersStatusBarHidden
{
    return YES;
}

#pragma clang diagnostic pop


@end
+2
source

All Articles