Every view comes with a series of modifiers that allow you to customize your view. Each modifier is custom to the view although some views share similar modifiers such as padding. These modifiers can provide accessibility features, add styles, provides actions, and even present other views.
Modifiers are added to a view way of a period. For example:
struct ContentView: View {
var body: some View {
Text("Hello, world!")
.padding()
}
}
This adds ten points of padding all around the Text. Notice that the modifier is placed on its own line. This arrangement makes it clear to anyone who reads the code.
Modifiers also stack on top of each other. For example:
The modifiers are processed in order. In this case, padding is placed around the Text followed by a border. Changing the order may change how the element looks on the screen. Often times, if something looks strange on screen, you may need to evaluate the order in which you are modifiers are being applied.
See forum comments
This content was released on Apr 24 2025. The official support period is 6-months
from this date.
Learn how to use modifiers to customize your views in SwiftUI.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.