0PricingLogin
SwiftUI Academy · Lesson

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

  1. Adding Padding Around Views
  2. Sizing Views with frame
  3. Backgrounds & Corner Radius
  4. Spacer & Layout Priority
← Back to SwiftUI Academy