Changing the Width of the Font in SwiftUI

Find out how to work with fonts in SwiftUI, and change the style, size, weight, color, and more of the text shown in the Text view.

If you use the.font() modifier with Text in SwiftUI, you may change its appearance. San Francisco is the iOS default font, and until you alter it, all of your text will have the basic iOS appearance.

To maintain a look that is consistent with iOS's default, choose any of the many terrific standard fonts.

Text("Simple Swift Guide").font(.largeTitle)

Title, headline, body, callout, caption, and footnote are all typical places for standard typefaces.

Text in the system's default typeface (San Francisco) may be resized as follows:

Text("Simple Swift Guide").font(.system(size: 56.0))

Altering the font-weight:

Text("Simple Swift Guide").fontWeight(.light)

Easily modify the system's default font along with its size, weight, and style:

Text("Simple Swift Guide").font(.system(size: 45, weight: .bold, design:.default))

Make the default headline font strong and italic:

Text("Simple Swift Guide").font(.headline).bold().italic()

Applying the.foregroundColor() modification to a typeface to alter its color:

Text("Simple Swift Guide").font(.callout).foregroundColor(.blue)

A more difficult topic, this second guide will show you how to implement a custom font family into your iOS app.

To help you quickly identify common typefaces, I've included the following: