理論上你可以直接調用字體名稱來使用字體。該字體的字體名稱是.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