我想对“AppearanceWhenContainedIn”调用(xcode 4.2,iOS 5.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

我想我的情况,因为按钮是在工具栏中,我在我的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]