ios - Monotouch 中的 UILabel 外观

标签 ios xamarin.ios uilabel uiappearance

为什么外观设置在 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;

给了我一个正确的结果。

最佳答案

好像是这个问题is not specific to MonoTouch .
引用约书亚 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.

这很烦人。

关于ios - Monotouch 中的 UILabel 外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13266344/

相关文章:

ios - 在 Xamarin Objective C 绑定(bind)中调用委托(delegate)时出现异常

xamarin - Json DeserializeObject 仅由 iOS 抛出异常

c# - Xamarin.iOS 上的 sqlite 中的缓慢 SELECT

arrays - 更改数组中的元素时更改 swift UILabel

ios - 如何在 XCode 中将字符串从一个单元测试传递到另一个单元测试?

ios - swift + 核心数据。从数据库中获取 N 个随机对象。 N << 尺寸(数据库)

iphone - 当文本太大时,文本不会显示在 UILabel 上。

ios - 如何用 subview 隐藏 UITextField 文本?

ios - 如何在 TableView 单元格之间进行分隔

ios - 如何在 iOS 的 subview 中停止滚动