您的位置:首页 > Web前端 > CSS

iOS状态栏设置样式

2017-04-20 15:11 330 查看
在info.plist中,将View controller-based status bar appearance设为NO

单独的一个页面

UIView *statusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 20)];
statusBarView.backgroundColor = [UIColor colorWithRed:36/255.0 green:58/255.0 blue:100/255.0 alpha:1];
[self.view addSubview:statusBarView];
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;


全局的

在appdelegate中

UIView *statusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, -20, self.window.frame.size.width, 20)];
statusBarView.backgroundColor = [UIColor colorWithRed:36/255.0 green:58/255.0 blue:100/255.0 alpha:1];
[self.navigationController.navigationBar addSubview:statusBarView];
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"navigationBar"] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios