2011-12-11 28 views
0

我在AppDelegate中調用了「AppearanceWhenContainedIn」方法來設置導航控制器類中所有按鈕的標題顏色。呼叫如下:我想對「AppearanceWhenContainedIn」調用(xcode 4.2,iOS 5.0)進行例外

[[UIButton appearanceWhenContainedIn:[UINavigationController class],nil] setTitleColor 
[UIColor colorWithRed:0 green:0.475 blue:0.227 alpha:1] forState:UIControlStateNormal]; 

這工作的方式我想它,然而,有一個UIView的,我有一個工具欄中的按鈕,我想保持按鈕白色的標題文字(不改變顏色)。按鈕和工具欄已添加到我的.xib文件中,並且我已將該按鈕附加到解除模式視圖控制器的IBAction(它是「關於」視圖)。

如何更改此特定按鈕的文本顏色,或在我的appearanceWhenContainedIn調用中發生異常?

非常感謝您的幫助。

+0

對不起,大家好,我找到了解決這個問題的辦法。謝謝。 – user1072337

回答

0

我想我的情況,因爲按鈕是在工具欄中,我在我的AppDelegate中使用customizeAppearance方法來更改工具欄中所有按鈕項的外觀。代碼是:

[[UIBarButtonItem appearance] setTitleTextAttributes: 
    [NSDictionary dictionaryWithObjectsAndKeys: 
     [UIColor whiteColor], 
     UITextAttributeTextColor, 
     [UIColor whiteColor], 
     UITextAttributeTextShadowColor, 
     [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], 
     UITextAttributeTextShadowOffset, 
     [UIFont fontWithName:@"ArialMT" size:0.0], 
     UITextAttributeFont, 
     nil]