سؤال

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!

هل كانت مفيدة؟

المحلول

This is how it's done.

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

Here is the UIApplication Class Reference

Hopefully this will help someone.

نصائح أخرى

I suspect that you can't do what you're trying to do.

The docs say that the animation when you call setStatusBarStyle is a slide animation:

statusBarStyle The current style of the status bar.

@property(nonatomic) UIStatusBarStyle statusBarStyle Discussion The value of the property is a UIStatusBarStyle constant that indicates the style of status. The default style is UIStatusBarStyleDefault. The animation slides the status bar out for the old orientation and slides it in for the new orientation.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top