[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;//黑
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;//白
一个新建的工程,紧紧这样设置是不行的。需要再plist文件里加上 View controller-based status bar appearance 并置为NO。如果置为YES就不行。
如果要修改状态栏背景色的变化,只需要
UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
statusBar.backgroundColor = [UIColor redColor];
}