Adding Padding Around Views
Use padding to create breathing room.
Why Views Feel Cramped
By default a SwiftUI view sits flush against its neighbors and the screen edge. Padding is the breathing room you add so content never feels squeezed.
Meet the padding Modifier
The padding modifier adds space on the outside of a view. Attach it like any other modifier and SwiftUI grows the view's footprint to make room.
Text("Hello")
.padding()All lessons in this course
- Adding Padding Around Views
- Sizing Views with frame
- Backgrounds & Corner Radius
- Spacer & Layout Priority