-1

i am trying to hide the status bar only for iPhone 6 and 6+ this is what i tried so far.

if (screenWidth == 375) {
        // Remove status bar for iPhone 6
        [[UIApplication sharedApplication] setStatusBarHidden:YES
                                                withAnimation:UIStatusBarAnimationFade];
    }else if (screenWidth == 414){
        // Remove status bar for iPhone 6 +
        [[UIApplication sharedApplication] setStatusBarHidden:YES
                                                withAnimation:UIStatusBarAnimationFade];
    }

5 Answers5

0

You can do (changing plist file):

set Status bar is initially hidden = YES

add row:

View controller-based status bar appearance = NO
Mihir Oza
  • 2,768
  • 3
  • 35
  • 61
baydi
  • 1,003
  • 6
  • 11
0

Add following line in viewDidLoad:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];

and add new method

- (BOOL)prefersStatusBarHidden {
          return YES;
  }

also change info.plist file

View controller-based status bar appearance" = NO

And also add condition for iPhone 6 and 6 Plus.Here are the methods for iPhone 6 and 6 Plus:

/*=====================================================================================================================
 Checks if the device has 4.7 inch screen such as iPhone6 generation
 =====================================================================================================================*/
+(BOOL) ISiPhone6
{
    BOOL isIpad = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad);
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    // we need to check the maximum of width and height because some screens (the camera view while scanning) we can
    // rotate to portrait or landscape and in the case the screen height and width flip
    return (!isIpad && MAX(screenRect.size.height,screenRect.size.width) == 667);
}

/*=====================================================================================================================
 Checks if the device has 5.5 inch screen such as iPhone6 plus 
 =====================================================================================================================*/
+(BOOL) ISiPhone6Plus
{
    BOOL isIpad = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad);
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    // we need to check the maximum of width and height because some screens (the camera view while scanning) we can
    // rotate to portrait or landscape and in the case the screen height and width flip
    return (!isIpad && MAX(screenRect.size.height,screenRect.size.width) == 736);
}  

it's works for me.

Mihir Oza
  • 2,768
  • 3
  • 35
  • 61
0

First: set this flag View controller-based status bar appearance to YES in the info.plist or add it as a new row
Second: override this method- (BOOL) prefersStatusBarHidden in each VC info you want to hide or see the status bar. For child view controller you need also to implement this method - (UIViewController *)childViewControllerForStatusBarHidden
Third: if you are changing status bar appearance at runtime you need to call his method to trigger the animation -setNeedsStatusBarAppearanceUpdate
All this methods help you in create a granular control on status bar appearance.
If you need yo make the status bar disappear while launching just flag Hide Status Bar in your target general settings.

Andrea
  • 26,120
  • 10
  • 85
  • 131
0

Since you just want to hide Status bar only in iPhone 6 and iPhone 6 Plus then You can do it like below. First add this in your class.

   #import <sys/utsname.h> 

Then in your viewDidLoad method

 NSString *platform;
struct utsname systemInfo;
uname(&systemInfo);
platform = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];

if ( [platform  isEqual:@"iPhone6,1"]||[platform  isEqual:@"iPhone6,2"]){
[[UIApplication sharedApplication] setStatusBarHidden:YES
                                            withAnimation:UIStatusBarAnimationFade];
}
riaz hasan
  • 1,155
  • 2
  • 8
  • 20
0

I have posted an answer for a similar question, you have to use the windowLevel of the UIApplication to hide/show the statusBar. Also we have to set the Viewcontroller based appearance property in the info.plist to NO.

daris mathew
  • 429
  • 5
  • 18