2013-03-19 85 views
3

下面给出的是我的导航栏的图像,其中右栏按钮现在处于禁用状态。但是当我禁用它的文本更改为白色。我不想要白色。任何解决方案。禁用栏按钮文字颜色变为白色?

启用编辑按钮时的第一个图像。 其他编辑按钮被禁用时。 在这种情况下,我们可以禁用按钮而不更改其文本颜色。提前

千恩万谢

这是自定义栏按钮

[[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:253.0/255.0 green:220.0/255.0 blue:135.0/255.0 alpha:1.0]]; 


[[UIBarButtonItem appearance] setTitleTextAttributes: 
[NSDictionary dictionaryWithObjectsAndKeys: 
    [UIColor blackColor], UITextAttributeTextColor, 
    [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0], UITextAttributeTextShadowColor, 
    [UIFont fontWithName:@"MyriadPro-Cond_0" size:16.0], UITextAttributeFont, nil] 
              forState:UIControlStateNormal]; 

这是栏按钮

UIBarButtonItem *rightBarBtnEdit=[[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UIBarButtonItemStyleBordered target:self action:@selector(methodEdit:)]; 
[rightBarBtnEdit setTag:701]; 
[self.navigationItem setRightBarButtonItem:rightBarBtnEdit]; 

这是禁用

self.navigationItem.rightBarButtonItem.enabled = NO; 

enter image description here

enter image description here

+1

给你的edite按钮代码... – iPatel 2013-03-19 06:18:57

+0

后编辑按钮代码与编辑按钮的初始配置 – Kasaname 2013-03-19 06:22:48

+0

嘿我把代码太 – 2013-03-19 07:24:57

回答

2

setTitleTextAttributes:forState:应针对您希望自定义的每个状态多次调用。目前您只需调用一次,对于UIControlStateNormal,对于其他状态,这些值将处于其默认值。

还可以用UIControlStateDisabled来调用它,以及任何你需要的属性。

+0

感谢兄弟,它的工作原理 – 2013-03-19 07:28:51