2011-07-24 184 views
13

我已经通过下面的代码目标C:如何更改文本颜色在导航栏

navconFvc.navigationBar.tintColor = [UIColor colorWithHexString:@"faf6f5"]; 

的代码工作改变了我的导航栏的颜色,但文本颜色也需要改变(见下图)。同样在右侧的刷新按钮徽标也会受影响

enter image description here

如果我导航到另一个页面在栈

enter image description here

问题发生同样的问题:我怎样才能改变在

  • 标题文本
  • 巴色CK按钮文字和
  • 右键按钮图标颜色?

当我改变了导航栏的背景颜色?

回答

15

对于这里的标题就是这样:

iPhone Navigation Bar Title text color

而对于这里的自定义按钮的方式:

adding buttons to ui navigation controller bottom bar

+1

林孔,法杜勒,感谢环节,第一环节很适合我。但是,我仍然不确定如何更改按钮的文本颜色或图标颜色。对于图标,我可能可以直接更改图像。但是,例如后退按钮的文字颜色呢?该链接并没有真正解释该部分 – Zhen

+0

旧的答案,使用@ Erwan的一个 – Zeb

1

我只是把一个简单的UIViewController子类,增加了一个可定制后退按钮,允许您更改文字颜色。它基本上增加了一些willAppear/willDisappear逻辑,使UINavigationController在使用leftBarButtonItem属性时的方式为后退按钮设置动画。您也可以将其扩展到右边的BarButtomItem。

https://github.com/typeoneerror/BBCustomBackButtonViewController

6

要更改文本颜色:

_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; 
15

在iOS系统7,只需使用:

self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]}; 

变化[的UIColor whiteColor]与任何文本颜色,你想