//设置状态栏颜色
- (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.navigationController setNavigationBarHidden:YES animated:YES];
[self setStatusBarBackgroundColor:[UIColor blackColor]];
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; // 默认为黑色
}
以及设置info.plist 中设置为NO
本文介绍如何使用Objective-C代码在iOS应用中设置状态栏的颜色,并提供了具体的实现方法,包括设置状态栏背景色及样式。
4239

被折叠的 条评论
为什么被折叠?



