3

I am trying to use UIAppearance to get a uniform color theme in my iOS app. For example I try to set the text color of all UILabel objects as follows:

[[UILabel appearance] setTextColor:[UIColor colorWithRed:0.7 green:0.07 blue:0.12 alpha:1]];

This works fine for all objects statically defined in my storyboard/XIBs. However, sometimes I need to dynamically create a UILabel in a view. In these cases, the UIAppearance is not used. Instead the default text color (black) is used instead.

Has anyone run into this issue/ found a way around it other than resorting to the old "set every element manually" approach?

jproch
  • 301
  • 2
  • 13
  • That's really odd. I notice that if I create the dynamic labels and **then** set their appearance it works...but I don't imagine that helps for most cases. – Phillip Mills Apr 12 '12 at 15:31
  • I actually tried that, but it didn't work for me either. So far, I just create the label and then call `myLabel.textColor = [[UILabel appearance] textColor]` to set it to whatever the current color UIAppearance color is, but it seems like that misses the point of UIAppearance. – jproch Apr 12 '12 at 15:35

1 Answers1

3

Seems that not all the classes support UIAppearance and UILabel is not one of those.

Check this question for more info: UIAppearance not taking effect on UILabels created programatically

Here's a list of classes that support UIAppearance: http://blog.mosheberman.com/list-of-classes-that-support-uiappearance-in-ios-5/

Community
  • 1
  • 1
PakitoV
  • 2,476
  • 25
  • 34