//设置状态栏颜色
- (void)setStatusBarBackgroundColor:(UIColor *)color {
UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];
if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]){
statusBar.backgroundColor = color;
}
}
然后调用
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self setStatusBarBackgroundColor:[UIColor redColor]];
}
本来是透明的,就会变成红色。
网友评论