如何将UIAppearance代理属性应用于UILabel? [英] How do I apply UIAppearance Proxy properties to UILabel?

查看:179
本文介绍了如何将UIAppearance代理属性应用于UILabel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试将UIAppearance代理样式应用于UILabel类代理时,我得到了不可靠的结果。例如,以下工作正如我所料:

I have been getting unreliable results while trying to apply UIAppearance proxy styles to the UILabel class proxy. For example, the following works as I would expect:

[[UILabel appearance] setFont:[UIFont fontWithName:SOME_FONT size:SOME_SIZE]];
[[UILabel appearance] setShadowColor:[UIColor blackColor]];

设置textColor不起作用,但是,这个:

Setting the textColor doesn't work, however, this:

[[UILabel appearance] setColor:[UIColor greenColor]];

确实有效。 。它有点不可靠,导致任何特定于实例的调用 setTextColor:被忽略。

does work. Kind of. It's somewhat unreliable and causes any instance-specific calls to setTextColor: to be ignored.

正确的方法是什么将UIAppearance样式应用于UILabel?

What is the correct way to apply UIAppearance styles to a UILabel?

推荐答案

好的,事实证明你无法设置任何UILabel属性的样式使用 UIAppearance 代理。

OK, it turns out that you cannot style any UILabel properties using the UIAppearance proxy.

虽然 UILabel class符合 UIAppearanceContainer 协议,对UILabel.h的检查显示其属性均未标记为 UI_APPEARANCE_SELECTOR ,使用 UIAppearance 的先决条件。

While the UILabel class conforms to the UIAppearanceContainer protocol, a check of UILabel.h shows that none of its properties are marked with UI_APPEARANCE_SELECTOR, the prerequisite for the use of UIAppearance.

Bugger。

这篇关于如何将UIAppearance代理属性应用于UILabel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆