美文网首页
在有导航栏的情况下,改变状态栏颜色

在有导航栏的情况下,改变状态栏颜色

作者: 奕珃 | 来源:发表于2017-07-18 15:43 被阅读0次

1、先获取状态栏的高度

// 状态栏(statusbar)

CGRect rectStatus = [[UIApplication sharedApplication] statusBarFrame];

NSLog(@"status width - %f", rectStatus.size.width); // 宽度

NSLog(@"status height - %f", rectStatus.size.height);  // 高度


// 导航栏(navigationbar)+ 状态栏 高度的宏定义

#define Nav_Height ([[UIApplication sharedApplication] statusBarFrame].size.height + self.navigationController.navigationBar.frame.size.height)

tabBar的高度

#define TabBar_Height self.tabBarController.tabBar.frame.size.height

自定义状态栏

UIView*statusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, -20,SCREEN_WIDTH, rectNav.size.height)];

statusBarView.backgroundColor= [UIColor redColor];

[self.navigationController.navigationBar addSubview:statusBarView];

相关文章

网友评论

      本文标题:在有导航栏的情况下,改变状态栏颜色

      本文链接:https://www.haomeiwen.com/subject/krdhkxtx.html