Backgrounds & Corner Radius
Apply colors, gradients, and rounded corners.
Adding a Background
The background modifier paints behind a view. Drop in a color and the area the view occupies fills in, instantly turning plain text into a tile.
Text("Hello")
.background(.blue)Pad First, Then Color
A background hugs the content tightly. Add padding before the background so the color has comfortable space around the text inside.
Text("Pill")
.padding()
.background(.blue)All lessons in this course
- Adding Padding Around Views
- Sizing Views with frame
- Backgrounds & Corner Radius
- Spacer & Layout Priority