2013-03-19 83 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