Search code examples
iosxamarin.iosuilabeluiappearance

UILabel Appearance in Monotouch


Why the appearance settings are not working on my controls in monotouch 6? I'm setting a properties

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

But when i'm creating a label

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

It looks like default label. With white background and dark text. And if i set a properties directly it works fine

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

Gives me a correct result.


Solution

  • It seems like this problem is not specific to MonoTouch.
    Quoting Joshua from another thread,

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

    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.

    Which is annoying.