【问题标题】:UILabel Appearance in MonotouchMonotouch 中的 UILabel 外观
【发布时间】:2012-11-07 09:04:55
【问题描述】:

为什么外观设置不适用于我在 monotouch 6 中的控件? 我正在设置属性

UILabel.Appearance.Font = UIFont.FromName("Fontname", 16);
UILabel.Appearance.BackgroundColor = UIColor.Clear;

但是当我创建一个标签时

UILabel mLabel = new UILabel(new RectangleF(0, 0, width, height));

它看起来像默认标签。白色背景和深色文本。 如果我直接设置属性,它工作正常

mLabel.Font = UIFont.FromName("Fontname", 16);
mLabel.BackgroundColor = UIColor.Clear;

给我一​​个正确的结果。

【问题讨论】:

    标签: ios xamarin.ios uilabel uiappearance


    【解决方案1】:

    好像是这个问题is not specific to MonoTouch.
    引用 another thread 的 Joshua,

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

    虽然UILabel 类符合UIAppearanceContainer 协议,但对UILabel.h 的检查表明它的所有属性都没有标记为UI_APPEARANCE_SELECTOR,这是使用UIAppearance 的先决条件。

    这很烦人。

    【讨论】:

    • 感谢您的澄清!最后我来到了我自己的代理类来创建 ui 控件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-19
    • 2019-11-26
    • 2012-04-06
    相关资源
    最近更新 更多