2013-05-29 64 views
0

我有一個酒吧按鈕項目,只能用於顯示在屏幕上執行某些內容時更新的字符串。我已將文字顏色設置爲白色。但是,它在屏幕上以灰色顯示。無論什麼顏色我改變文字,我仍然得到一個灰色的顏色,而不是所需的顏色。爲什麼我沒有得到正確的顏色?這是我遺失的財產嗎?標題文本顏色在酒吧按鈕項目

UIColor *buttonColor = [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0]; 
_timeButton.title = [NSString stringWithFormat:@"Updated at: %@",dateString]; 
[_timeButton setStyle:UIBarButtonItemStylePlain]; 
_timeButton.tintColor = [UIColor clearColor]; 
[_timeButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: 
            [UIFont boldSystemFontOfSize:15], UITextAttributeFont, 
            buttonColor ,UITextAttributeTextColor, 
             nil] 
             forState:UIControlStateNormal]; 
+0

看看這個:http://stackoverflow.com/questions/664930/uibarbuttonitem-with-color – Anil

+0

感謝您的鏈接。但是,該線程中沒有任何內容與在普通欄按鈕項目上設置文本有關。我的問題是我的文本不是[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:1.0];但更接近[UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:.5];我想要後者。 – DaveLass

回答

0

原來我的按鈕顏色是灰色的,因爲按鈕沒有啓用。將按鈕設置爲啓用將文本的顏色更改爲白色。

[_timeButton setEnabled:YES];