UIFont - how to get system thin font

MiguelSlv picture MiguelSlv · Aug 2, 2015 · Viewed 54.2k times · Source

UIFont has methods to get regular font (systemFontOfSize) or bold font (boldSystemFontOfSize), but how to get a "thin system font" available through storyboard?

Passing "system-thin" to UIFont Contructor doesn't work, this constructor only works for non system fonts.

Answer

s1ddok picture s1ddok · Aug 2, 2015

You can use system font thin weight:

UIFont.systemFont(ofSize: 34, weight: UIFontWeightThin)

List of available weights for San Francisco:

UIFontWeightUltraLight
UIFontWeightThin
UIFontWeightLight
UIFontWeightRegular
UIFontWeightMedium
UIFontWeightSemibold
UIFontWeightBold
UIFontWeightHeavy
UIFontWeightBlack

san francisco font weights

As of iOS 11, UIFontWeight* was renamed to UIFont.Weight.*. More you can get here https://developer.apple.com/documentation/uikit/uifont.weight.