如何以编程方式设置wC hR字体大小?
答
let wSize = self.view.traitCollection.horizontalSizeClass
let hSize = self.view.traitCollection.verticalSizeClass
if wSize == UIUserInterfaceSizeClass.Compact && hSize == UIUserInterfaceSizeClass.Regular {
button.titleLabel?.font = UIFont(name: FontNameCode, size: size)
}
+0
我正在使用Objective C.你能给我提供代码吗? –
+0
对不起,我在你的文章中遗漏了这个标签。我真的不知道Obj-C足够好转换它。但是你只需要创建两个'UIUserInterfaceSizeClass'对象,然后检查它们是否合适。 – Tim
http://*.com/questions/1465305/set-uibutton-title-uilabel-font-size-programmatically – Skywalker