1.狀態(tài)欄的顏色
[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.根據(jù)顏色生成圖片
- (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;
}