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

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];

你可能感兴趣的:(在有导航栏的情况下,改变状态栏颜色)