Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Some UI elements don't acquire UIAppearance traits

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?

like image 242
jproch Avatar asked Feb 26 '26 14:02

jproch


1 Answers

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/

like image 51
PakitoV Avatar answered Feb 28 '26 04:02

PakitoV



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!