1.状态栏的颜色
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
2.导航栏的颜色
self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
self.navigationController.navigationBar.translucent = NO;
self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
3.返回按钮的颜色
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
4.去掉导航栏下面的分割线
[self.navigationController.navigationBar setBackgroundImage:[self GetImageWithColor:MainColor andHeight:64*MyHeight] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[self GetImageWithColor:MainColor andHeight:1]];
5.设置导航栏Title的颜色和字体
[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:SLLFont(18),NSForegroundColorAttributeName:[UIColor whiteColor]}];
6.修改返回按钮的样式,去掉“back”,在AppDelegate中设置
[[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateNormal];
7.根据颜色生成图片
- (UIImage*)GetImageWithColor:(UIColor*)color andHeight:(CGFloat)height
{
CGRect r= CGRectMake(0.0f, 0.0f, 1.0f, height);
UIGraphicsBeginImageContext(r.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [color CGColor]);
CGContextFillRect(context, r);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}