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.