Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS : Hide status bar in entire app programmatically not even through plist

I want to hide status bar in my entire app.

Also I know it too, that we can do it by this way :

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 there need some condition for OS version and as of my knowledge we can not apply any condition in .plist file.

So anyone please suggest some line of code which only hide status bar for iOS 7.

Appreciate on your response.

like image 662
Sunil Targe Avatar asked Dec 11 '22 09:12

Sunil Targe


2 Answers

add the following code to your view controllers:

- (BOOL)prefersStatusBarHidden {
    return YES;
}

this will not disturb any ios below 7 because it is only called in ios7.

like image 60
Bastian Avatar answered Dec 13 '22 23:12

Bastian


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

Add this code into application didFinishLaunchingWithOptions method.

like image 32
Sunil Targe Avatar answered Dec 13 '22 22:12

Sunil Targe