//设置状态栏颜色
-
(void)setStatusBarBackgroundColor:(UIColor *)color {
UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"]; if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) { statusBar.backgroundColor = color; } }
-
(void)viewDidLoad { [super viewDidLoad];
[self setStatusBarBackgroundColor:[UIColor redColor]]; self.view.backgroundColor = [UIColor yellowColor]; }
//设置字的颜色
- (UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; }
1.plist设置statusBar
在plist里增加一行 UIStatusBarStyle(或者是“Status bar style”也可以),这里可以设置两个值,就是上面提到那两个 UIStatusBarStyleDefault 和 UIStatusBarStyleLightContent 2.程序代码里设置statusBar [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 3.在plist文件中添加 View controller-based status bar appearance = NO。