【发布时间】:2015-07-03 22:12:01
【问题描述】:
我尝试通过外观代理设置UIButton 的字体。但这似乎不起作用。这是我尝试过的。
UIButton.appearance().titleFont = UIFont(name: FONT_NAME_DEFAULT, size:20.0)
UIButton.appearance().titleLabel?.font = UIFont(name: FONT_NAME_DEFAULT, size:20.0)
如何在 iOS 8 中通过外观代理设置UIButton 字体?
编辑:在 vaberer 的 link 中找到:“我很惊讶 UIButton 没有任何 UI_APPEARANCE_SELECTOR 属性,但符合 UIAppearance 协议。”
【问题讨论】:
-
从 iOS 9 开始,您可以使用
UILabel.appearance(whenContainedInInstancesOf: [UIButton.self]).font = ...
标签: ios swift uibutton uiappearance