Change Font Size with SwiftUI | Hacking Swift 5.5, Xcode 13, and iOS 15

Increase or Decrease Text Size with Swift

by Alexandra Kropova from Mammoth Interactive

Want to learn more? Enroll in Complete Web & App Development with Machine Learning For All (125 Hours). Free in the Mammoth Unlimited Membership. Get 250+ courses and 2,000 hours at a dirt-cheap price.

To change the font size of a Text element or another element in SwiftUI, use the following code:

.font(.system(size: 60))

Understanding this property:

The font property is added to an element.

The font type is .system, which refers to the default OS system font.

The font size is set to 60.

Using the property on an element

This property should be attached to the element right after the element’s body.

Here is an example of using this property on a Text element:

Text("My text")
.font(.system(size: 60)) 

Suggest more solutions or ask a question in the comments below.

Want to learn more? Enroll in Complete Web & App Development with Machine Learning For All (125 Hours). Free in the Mammoth Unlimited Membership. Get 250+ courses and 2,000 hours at a dirt-cheap price.
Mammoth Interactive Favicon

Why you NEED to take this course :

Get in Touch.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

EMAIL US

support@mammothinteractive.com