//導(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)題顏色改變,通過(guò)以下方法修改
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
自定義的按鈕圖片距屏幕邊緣太遠(yuǎn)励稳,可通過(guò)以下代碼修改
系統(tǒng)默認(rèn)的rightBarButtonItem邊距
self.navigationItem.leftBarButtonItem.imageInsets = UIEdgeInsetsMake(0,-20,0,0);
self.navigationItem.rightBarButtonItem.imageInsets = UIEdgeInsetsMake(0,-10,0,10);