理论上你可以直接调用字体名称来使用字体。该字体的字体名称是.SFUIDisplay-Bold
。
然而,苹果不鼓励这种方法,并说这些字体名称是私人的,随时都可能改变。
使用旧金山字体官方的方法是调用systemFont
自动给你旧金山字体:
let font = UIFont.systemFontOfSize(17)
为了得到从轻或较粗的字体,你可以请求字体粗细:
let mediumFont = UIFont.systemFontOfSize(17, weight: UIFontWeightMedium)
let lightFont = UIFont.systemFontOfSize(17, weight: UIFontWeightLight)
let boldFont = UIFont.systemFontOfSize(17, weight: UIFontWeightBold)
有一吨的字体粗细的选择:
UIFontWeightUltraLight
UIFontWeightThin
UIFontWeightLight
UIFontWeightRegular
UIFontWeightMedium
UIFontWeightSemibold
UIFontWeightBold
UIFontWeightHeavy
UIFontWeightBlack
钍e SF的显示变体用于文本的大型显示。不适用于iPhone标签。 – Fogmeister