參考?http://m.itdecent.cn/p/889cff2b3a52
- (void)viewWillAppear:(BOOL)animated{
??? [superviewWillAppear:animated];
?//status bar的字體為白色 ,導(dǎo)航欄的背景色是黑色。? 設(shè)置為UIBarStyleDefault statusbar 為黑色
?self.navigationController.navigationBar.barStyle=?UIBarStyleBlack;
?//如果 info.plist 將View controller-based status bar appearance 設(shè)為 NO ?改變 statusbar 顏色需要使用下邊
??? [UIApplicationsharedApplication].statusBarStyle=?UIStatusBarStyleLightContent;
?//更改返回按鈕的顏色
?self.navigationController.navigationBar.tintColor= [UIColorwhiteColor];
?// 設(shè)置導(dǎo)航欄title顏色和字體大小
?NSMutableDictionary*attributes = [NSMutableDictionarydictionary];
??? attributes[NSForegroundColorAttributeName] = [UIColorwhiteColor];
??? attributes[NSFontAttributeName] =?GKBlodFont(AUTO(18));
?self.navigationController.navigationBar.titleTextAttributes= attributes;
#mark 由于我們要實(shí)現(xiàn)的效果 ?是在不同的頁面導(dǎo)航欄的顏色不同 標(biāo)題的顏色不同 有時候會遇到這個 title 的字體顏色不改變 可以使用下邊的方法解決
UILabel?*titleLabel = [[UILabel
alloc]initWithFrame:CGRectMake(0,0,200,44)];
titleLabel.backgroundColor?= [UIColor grayColor];
titleLabel.font?= [UIFont boldSystemFontOfSize:20];
titleLabel.textColor?= [UIColor greenColor];
titleLabel.textAlignment=NSTextAlignmentCenter;
titleLabel.text?= @"啊啊啊啊啊啊啊啊";
self.navigationItem.titleView?= titleLabel;
?//設(shè)置導(dǎo)航欄的背景顏色
?UIImage*image = [XDCommonToolimageWithColor:RGB(254,?111,?89)];
??? [self.navigationController.navigationBarsetShadowImage:image];
??? [self.navigationController.navigationBarsetBackgroundImage:image?forBarMetrics:UIBarMetricsDefault];
}