修改導(dǎo)航欄中的標(biāo)題的字體的顏色

方法一:(自定義視圖的方法,一般人也會(huì)采用這樣的方式)

就是在導(dǎo)航向上添加一個(gè)titleView,可以使用一個(gè)label,再設(shè)置label的背景顏色透明,字體什么的設(shè)置就很簡(jiǎn)單了。

//自定義標(biāo)題視圖

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;

方法二:(在默認(rèn)顯示的標(biāo)題中直接修改文件的大小和顏色也是可以的)

[self.navigationController.navigationBar setTitleTextAttributes:

@{NSFontAttributeName:[UIFont systemFontOfSize:19],

NSForegroundColorAttributeName:[UIColor redColor]}];



//修改導(dǎo)航條背景色(紅褐色)self.navigationController.navigationBar.barTintColor = RGB(175,24,50,1.0);其中RGB為我的工程里的一個(gè)宏定義:#define RGB(r,g,b,a)? [UIColor colorWithRed:(r/255.0) green:(g/255.0) blue:(b/255.0) alpha:(a)]//修改導(dǎo)航條標(biāo)題顏色(白色)[self.navigationController.navigationBar setTitleTextAttributes:[NSDictionarydictionaryWithObjectsAndKeys:[UIColorwhiteColor],NSForegroundColorAttributeName,nil]];//修改導(dǎo)航條添加的按鈕(item)顏色(黃色)self.navigationController.navigationBar.tintColor = [UIColoryellowColor];

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

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

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