From the course: SwiftUI Essential Training

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Basic backgrounds

Basic backgrounds

- [Instructor] We've looked at foregrounds. Now let's look at backgrounds. Until we set a nice color for the foreground, we used a background modifier to help us see the title in the HeaderView. You can use background modifiers in any view replacing the transparent background with a color. Now we have several of the same choice for colors we had for foregrounds plus a few more. Commonly, you'll place backgrounds on stacks or views giving a background to all the stacks or views. For example, I'm going to go into OrderView here and I could put this VStack. And I'm going to go up here. I'm going to collapse the VStack for a sec and I'm going to put underneath this VStack a background. And then inside the background, I'm going to put a Color and we'll use Surf for this. And now the whole background is that color. If I had done this with padding afterwards, notice what happens. The padding pushes the background inward a…

Contents