一、状态栏(statusBar)
默认:黑色
改变为白色:
第一步:
info.plist中添加View controller-based status bar appearance为NO
第二步:
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
UIApplication.shared.statusBarStyle = .lightContent
二、导航栏(navigationBar)
1、改变导航栏背景颜色
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
navigationController?.navigationBar.barTintColor = UIColor.red
2、改变导航栏字体
白色
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
navigationController?.navigationBar.barStyle = .black
任意颜色、字体大小
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor], NSFontAttributeName:[UIFont systemFontOfSize:25]}];
3、改变导航栏背景为图片
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"image"] forBarMetrics:UIBarMetricsDefault];
4、取消导航栏按钮Item图片被渲染的效果
方法一:通过代码设置
image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
方法二:通过Assets.xcassets设置
找到对应图片的Image Set栏,Render as设置为Original Image.
Assets.xcassets设置