How to access the iOS system font programmatically

Solution 1:

I think you need:

NSFontAttributeName : UIFont.systemFontOfSize(19.0)

Or the bold version:

NSFontAttributeName : UIFont.boldSystemFontOfSize(19.0)

See this guide for more info on user interface guidelines and fonts.

Solution 2:

You can access the system font like this, and even set the weight of the font:

  • Swift 3, Swift 4

    UIFont.systemFont(ofSize: 18, weight: UIFontWeightLight)

  • Swift 2

    UIFont.systemFontOfSize(18, weight: UIFontWeightLight)

For the font weight you have the choice between those constants, there available from iOS 8.2:

UIFontWeightUltraLight,
UIFontWeightThin,
UIFontWeightLight,
UIFontWeightRegular,
UIFontWeightMedium,
UIFontWeightSemibold,
UIFontWeightBold,
UIFontWeightHeavy,
UIFontWeightBlack

Solution 3:

SWIFT 4+: shorter version

UIFont.systemFont(ofSize: 14.0, weight: .regular)