将标签的字体设置为SF UI Display Bold时出现问题。
仅当布尔值为false时,我才不想设置此持久性。
if (value.messageReaded == false) {
cell.subjectLabel?.font = UIFont(name:"SF UI Display Bold", size: 17.0)
}
不幸的是,我的方法不适用于这种字体。
你们有人迅速知道“ SF UI Display Bold”字体的正确标题吗?
谢谢!
从理论上讲,您可以通过直接调用其字体名称来使用该字体。该字体的字体名称为.SFUIDisplay-Bold
。
但是,Apple不鼓励采用这种方法,并说这些字体名称是私有的,随时可能更改。
使用San Francisco字体的官方方法是调用systemFont
,它会自动为您提供San Francisco字体:
let font = UIFont.systemFont(ofSize: 17)
要获得更浅或更粗的字体,您可以请求字体粗细:
let mediumFont = UIFont.systemFont(ofSize: 17, weight: UIFont.Weight.medium)
let lightFont = UIFont.systemFont(ofSize: 17, weight: UIFont.Weight.light)
let boldFont = UIFont.systemFont(ofSize: 17, weight: UIFont.Weight.bold)
有大量的字体粗细可供选择:
UIFont.Weight.ultraLight
UIFont.Weight.thin
UIFont.Weight.light
UIFont.Weight.regular
UIFont.Weight.medium
UIFont.Weight.semibold
UIFont.Weight.bold
UIFont.Weight.heavy
UIFont.Weight.black
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句