gpt4 book ai didi

ios - 如何更改状态栏的背景颜色而不是导航栏的背景颜色?

转载 作者:行者123 更新时间:2023-11-29 01:22:19 25 4
gpt4 key购买 nike

根目录: enter image description here

推Vc: enter image description here

如何实现这个效果?

如何改变状态栏的背景色而不改变导航栏的背景色?

最佳答案

将此方法添加到您的每个 View Controller ,或(从类别方法中调用它)

-(void)status_bar_color
{
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
{
UIView *addStatusBar = [[UIView alloc] init];
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height >750)
{
addStatusBar.frame = CGRectMake(0, 0, 800, 23);
}
else if(result.height >550)//IPod
{
addStatusBar.frame = CGRectMake(0, 0, 320, 23);
}
else
{
addStatusBar.frame = CGRectMake(0, 0, 320, 23);
}

addStatusBar.backgroundColor=[UIColor blackColor];
[self.view addSubview:addStatusBar];
}
}

statusbar的浅色内容,也用这个方法,

-(UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}

很酷..

关于ios - 如何更改状态栏的背景颜色而不是导航栏的背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34448225/

25 4 0