導(dǎo)航欄設(shè)置

//導(dǎo)航欄按鈕設(shè)置

//導(dǎo)航欄背景色全局設(shè)置(寫在appdelegate里)

[[UINavigationBar appearance] setBarTintColor:kMainColorOfApp];

//按鈕標(biāo)題顏色設(shè)置

[self.navigationController.navigationBar setTintColor:[UIColor blackColor]];

//按鈕標(biāo)題設(shè)置

self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(onClickCancel)];

self.navigationItem.rightBarButtonItem =? [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(onClickSave)];

self.navigationItem.title = @"服務(wù)地區(qū)";

修改導(dǎo)航條背景顏色

self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#2295f2"];

設(shè)置了導(dǎo)航條背景顏色,會(huì)導(dǎo)致按鈕標(biāo)題顏色改變,通過以下方法修改

self.navigationController.navigationBar.tintColor = [UIColor whiteColor];

自定義的按鈕圖片距屏幕邊緣太遠(yuǎn),可通過以下代碼修改

系統(tǒng)默認(rèn)的rightBarButtonItem邊距

self.navigationItem.leftBarButtonItem.imageInsets = UIEdgeInsetsMake(0,-20,0,0);

self.navigationItem.rightBarButtonItem.imageInsets = UIEdgeInsetsMake(0,-10,0,10);

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容