Search code examples
ios4xcode4ios5

I would like to make an exception to the "AppearanceWhenContainedIn" call (xcode 4.2, iOS 5.0)


I have called a the "AppearanceWhenContainedIn" method in my AppDelegate to set the the title color of all of my buttons in Navigation Controller classes. The call is as follows:

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

This works the way I want it to, however, there is one UIView where I have a button in a toolbar that I want to keep the title text of the button white (not change the color). The button and toolbar were added in my .xib file and I have the button attached to an IBAction that dismisses the modal view controller (it's an "About" view).

How would I change the text color of this specific button, or make an exception in my appearanceWhenContainedIn call?

Thank you very much for your help.


Solution

  • I guess in my case, because the button was in a toolbar, I used a customizeAppearance method in my AppDelegate to change the appearance of all button items in toolbars. The code was:

    [[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]