Search code examples
iosios7uiviewanimationuistatusbar

iOS 7 How to animate StatusBarStyle from DefaultContent to LightContent


I am trying to transition the status bar style from UIStatusBarStyleDefaultContent to UIStatusBarStyleLightContent using a UIView animation, however, the style just switches with no fade animation. I figured that setting the style using the following would work:

[UIView animateWithDuration:1.0
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{
                     [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
                     [self.view layoutIfNeeded];
                 } completion:nil];

I am not sure how to get what I want to happen. Basically, my content changes from dark to light so I need to change the status bar color. By default it doesn't work the way I want. Any help is much appreciated.

Thanks!


Solution

  • This is how it's done.

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

    Here is the UIApplication Class Reference

    Hopefully this will help someone.