我正在尝试使用UIAppearance
在我的iOS应用中获得统一的颜色主题。例如,我尝试按如下方式设置所有UILabel
个对象的文本颜色:
[[UILabel appearance] setTextColor:[UIColor colorWithRed:0.7 green:0.07 blue:0.12 alpha:1]];
这适用于我的storyboard / XIB中静态定义的所有对象。但是,有时我需要在视图中动态创建UILabel。在这些情况下,不使用UIAppearance。而是使用默认文本颜色(黑色)。
有没有人遇到这个问题/找到解决方法而不是诉诸旧的“手动设置每个元素”的方法?
答案 0 :(得分:3)
似乎并非所有类都支持UIAppearance而且UILabel不是其中之一。
查看此问题以获取更多信息: UIAppearance not taking effect on UILabels created programatically
以下是支持UIAppearance的类列表: http://blog.mosheberman.com/list-of-classes-that-support-uiappearance-in-ios-5/