//改变状态栏字体颜色
-(UIStatusBarStyle)preferredStatusBarStyle
{
//状态栏字体颜色
returnUIStatusBarStyleLightContent;
}
self.navigationController.navigationBar.translucent = NO;
self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#1f2227" withAlpha:1];
UIView *statusBarView = [[UIView alloc]initWithFrame:CGRectMake(0, -20,
[[UIScreen mainScreen]bounds].size.width,20)];
//将它的颜色设置成你所需要的,这里我选择了黑色,表示我很沉稳
statusBarView.backgroundColor=[UIColor blackColor];
//这里我的思路是:之前不理想的状态是状态栏颜色也变成了导航栏的颜色,但根据这种情况,反而帮助我判断出此时的状态栏也是导航栏的一部分,而状态栏文字浮于上方,因此理论上直接在导航栏上添加一个subview就是他们中间的那一层了。
//推得这样的代码:
[self.navigationController.navigationBar addSubview:statusBarView];