iOS 7如何将StatusBarStyle从DefaultContent设置为LightContent

cri*_*ald 4 uiviewanimation ios uistatusbar ios7

我正在尝试使用UIView动画将状态栏样式从UIStatusBarStyleDefaultContent转换UIStatusBarStyleLightContent,但是,样式只是在没有淡入淡出动画的情况下切换.我认为使用以下方式设置样式会起作用:

[UIView animateWithDuration:1.0
                      delay:0.0
                    options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{
                     [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
                     [self.view layoutIfNeeded];
                 } completion:nil];
Run Code Online (Sandbox Code Playgroud)

我不知道如何得到我想要发生的事情.基本上,我的内容从黑暗变为浅,所以我需要更改状态栏颜色.默认情况下,它不能按我想要的方式工作.任何帮助深表感谢.

谢谢!

cri*_*ald 6

这就是它的完成方式.

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
Run Code Online (Sandbox Code Playgroud)

这是UIApplication类参考

希望这会对某人有所帮助.