gpt4 book ai didi

ios - 一些 UI 元素不获取 UIAppearance 特征

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:07:57 24 4
gpt4 key购买 nike

我正在尝试使用 UIAppearance 在我的 iOS 应用程序中获得统一的颜色主题。例如,我尝试将所有 UILabel 对象的文本颜色设置如下:

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

这适用于我的 Storyboard/XIB 中静态定义的所有对象。但是,有时我需要在 View 中动态创建 UILabel。在这些情况下,不使用 UIAppearance。而是使用默认文本颜色(黑色)。

除了诉诸旧的“手动设置每个元素”方法之外,是否有人遇到过这个问题/找到了解决方法?

最佳答案

似乎并非所有类都支持 UIAppearance,而 UILabel 不是其中之一。

查看此问题以获取更多信息: UIAppearance not taking effect on UILabels created programatically

下面是支持 UIAppearance 的类列表: http://blog.mosheberman.com/list-of-classes-that-support-uiappearance-in-ios-5/

关于ios - 一些 UI 元素不获取 UIAppearance 特征,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10126405/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com