ios更改導(dǎo)航欄顏色 字體大小 狀態(tài)欄顏色

參考?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];


}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容