参考文档1
参考文档2
参考文档3
参考文档
状态栏颜色分为两种:
UIStatusBarStyleDefault 黑色
UIStatusBarStyleLightContent 白色
设置状态栏颜色 :
前景色
方法A:
- info.plist 中
View controller-based status bar appearance 设为 NO - AppDelegate中
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault; - 个别VC状态栏修改
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated]
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}
方法 B:
1、plist
View controller-based status bar appearance 设置为 YES
注意:View controller-based status bar appearance为YES时[UIApplication sharedApplication].statusBarStyle 无效。
- 代码
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
背景色 【StatusBar/NavigationBar】方法 A: 系统方法
self.navigationController.navigationBar.barTintColor = [UIColor greenColor];
//如果想将状态栏和导航栏字体全变为白色
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
//如果只想改变导航栏的字体颜色大小
[self.navigationController.navigationBar setTitleTextAttributes:
@{NSForegroundColorAttributeName:[UIColor redColor],NSFontAttributeName:[UIFont systemFontOfSize:25]}];
//或者可以设置背景图片
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"image"] forBarMetrics:UIBarMetricsDefault];
导航栏颜色
//Baritem 颜色
[UINavigationBar appearance].tintColor = [UIColor orangeColor];
//调整导航栏背景图片
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"m_nav64"] forBarMetrics:UIBarMetricsDefault];
//调整导航栏背景色
[UINavigationBar appearance].barTintColor = [UIColor orangeColor];
//半透明开关
self.navigationController.navigationBar.translucent = NO;
//为导航栏添加背景图片,图片如果是44高,那么不覆盖状态栏,
//如果是64高就会覆盖状态栏
//UIBarMetricsDefault 缺省值
//UIBarMetricsCompact 横屏样式
//UIBarMetricsDefaultPrompt和UIBarMetricsCompactPrompt是有promt的两种样式
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"m_nav64"] forBarMetrics:UIBarMetricsDefault];
//修改导航栏标题的字体
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
shadow.shadowOffset = CGSizeMake(0, 1);
//字典中放入你想修改的键值对,原来的UITextAttributeFont、UITextAttributeTextColor、UITextAttributeTextShadowColor、UITextAttributeTextShadowOffset已弃用
self.navigationController.navigationBar.titleTextAttributes
=
@{NSForegroundColorAttributeName:[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0],
NSShadowAttributeName:shadow,
NSFontAttributeName:[UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0]
};