Search code examples
iosiphoneobjective-cuitextfielduistatusbar

uitextfield selected changes status bar color


I can't find what is wrong with UITextField (or UIStatusBar).

In my

- (BOOL)application:(UIApplication *)application 
        didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

I have:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

Also in my view controller I have this:

-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}

The color of UIStatusBar is always white as I want it to be. But whenever I select UITextField, it's color changes to black. I don't want that, and I always want it to be white.

Strange but I can't find any similar issues on the net, so I'm hoping for your help. Any help is appreciated. Thanks in advance!


Solution

  • If you always want the UIStatusBar with whiteColor insert the line like you did in didFinishLaunching

    [[UIApplication sharedApplication]
       setStatusBarStyle:UIStatusBarStyleLightContent];
    

    and than also set a value for the statusbar inside info.plist like this

    enter image description here

    You just need to set preferredStatusBarStyle inside a UIViewController if you want to change the color for a single controller.