UIFont - how to get system thin font UIFont - how to get system thin font ios ios

UIFont - how to get system thin font


You can use system font thin weight:

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

List of available weights for San Francisco:

UIFontWeightUltraLightUIFontWeightThinUIFontWeightLightUIFontWeightRegularUIFontWeightMediumUIFontWeightSemiboldUIFontWeightBoldUIFontWeightHeavyUIFontWeightBlack

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.


As of iOS 8.2, you can now use UIFont.systemFontOfSize(_ fontSize: CGFloat, weight weight: CGFloat):

UIFont.systemFontOfSize(19, weight: UIFontWeightLight)

iOS SDK provided constants for weights:

UIFontWeightUltraLightUIFontWeightThinUIFontWeightLightUIFontWeightRegularUIFontWeightMediumUIFontWeightSemiboldUIFontWeightBoldUIFontWeightHeavy

Using system font is better than creating a font based on font name when you want to use system fonts since iOS can change their system fonts on iOS (like when they did with Helvetica Neue in iOS 7, and now, San Francisco in iOS 9).

So what I would suggest is to include TTF file of the font you want as use that ttf file as custom font and use the custom font in your app.

This is the special reason why I don't like Apple. Never go what Apple say. Always do what we want. Apple keep on changing Default font for every OS.


Also if you want to keep same font size and just change weight then use from targeted element font size. For example:

demoLabel.font = UIFont.systemFont(ofSize: demoLabel.font.pointSize, weight: UIFontWeightThin)

with this you can keep default label font size and just change weight.

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