Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change UIViewControllerBasedStatusBarAppearance to YES/NO programmatically in iOS 7?

My application has a dark background, but in iOS 7 the status bar became transparent. So I can't see anything there, only green battery indicator in the corner. How can I change the status bar text color to Green or Orange like it is on the home screen?

I know about

  1. Set the UIViewControllerBasedStatusBarAppearance to YES in the plist

  2. In viewDidLoad do a [self setNeedsStatusBarAppearanceUpdate];

  3. Add the following method:

    -(UIStatusBarStyle)preferredStatusBarStyle{ 
        return UIStatusBarStyleLightContent; 
    }
    

How can I change UIViewControllerBasedStatusBarAppearance programmatically?

Thanks in advance...

like image 373
kagmanoj Avatar asked Jan 29 '14 07:01

kagmanoj


1 Answers

In Info.plist set 'View controller-based status bar appearance' as NO.

then,add this in your appdelegate.m class in didfinishlaunchingwithoptions method.

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];

this works for ios 7.

like image 82
gunas Avatar answered Sep 29 '22 16:09

gunas