[英]Change navigation bar color/font to default when sending email, text message, etc (Objective-C)
[英]Objective C: How to change text color in navigation bar
我通過以下代碼更改了導航欄顏色
navconFvc.navigationBar.tintColor = [UIColor colorWithHexString:@"faf6f5"];
代碼工作但文本顏色也需要更改(見下面的截圖)。 此外,右側的刷新按鈕徽標也會受到影響
如果我導航到堆棧中的另一個頁面,則會出現同樣的問題
問題:如何更改顏色
我改變了導航欄的背景顏色后?
在iOS 7中,只需使用:
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};
使用您想要的任何文本顏色更改[UIColor whiteColor]
要更改文字顏色:
_navController.navigationBar.titleTextAttributes
= @{UITextAttributeTextColor : [UIColor blackColor]};
添加刷新按鈕並為其着色:
UIBarButtonItem *button = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
target:self action:@selector(reload)];
[button setTintColor:[UIColor blackColor]];
self.navigationItem.rightBarButtonItem = button;
影響導航欄背景的變量:
_navController.navigationBar.backgroundColor = [UIColor whiteColor];
_navController.navigationBar.tintColor = [UIColor whiteColor];
_navController.navigationBar.translucent = NO;
我只是將一個簡單的UIViewController
子類放在一起,它添加了一個可自定義的后退按鈕,允許您更改文本顏色。 它基本上添加了一些willAppear
/ willDisappear
邏輯來設置后退按鈕的動畫,就像UINavigationController
在使用leftBarButtonItem
屬性時一樣。 您也可以將其擴展為也執行rightBarButtomItem。
https://github.com/typeoneerror/BBCustomBackButtonViewController
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.