直接贴代码
//设置导航栏背景色
UIBarButtonItem *barItem = [UIBarButtonItem appearance];
UIImage *bg6 = [UIImage imageWithColor:UIColorFromRGB(78, 157, 225) size:CGSizeMake(1, 44)];
UIImage *bg7 = [UIImage imageWithColor:UIColorFromRGB(78, 157, 225) size:CGSizeMake(1, 64)];
if (!IOS7)
{
[navigationBarAppearance setBackgroundImage:bg6 forBarMetrics:UIBarMetricsDefault];
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
else
{
[navigationBarAppearance setBackgroundImage:bg7 forBarMetrics:UIBarMetricsDefault];
};
//UIColorFromRGB(255, 255, 255)
[barItem setTitleTextAttributes:@{
NSForegroundColorAttributeName:[UIColorwhiteColor],
NSFontAttributeName:[UIFontsystemFontOfSize:14]
}forState:UIControlStateNormal];
//设置文字颜色
NSDictionary *textAttributes = nil;
if ([[[UIDevice currentDevice] systemVersion] integerValue] >= 7.0) {
textAttributes = @{
NSFontAttributeName: [UIFont boldSystemFontOfSize:18],
NSForegroundColorAttributeName: [UIColor whiteColor],
};
} else {
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
textAttributes = @{
UITextAttributeFont: [UIFont boldSystemFontOfSize:18],
UITextAttributeTextColor: [UIColor whiteColor],
UITextAttributeTextShadowColor: [UIColor clearColor],
UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetZero],
};
#endif
}
[navigationBarAppearance setTitleTextAttributes:textAttributes];