From the course: Programming for Non-programmers: iOS 17 and Swift 5

Unlock this course with a free trial

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

SwiftUI layout basics

SwiftUI layout basics

- [Instructor] Now, we're at the point where we've discussed enough foundational programming concepts to start building our calculator. We're going to start with creating the calculator layout of the buttons. To do that, we're going to use something called a grid, and we're going to talk about the various layout options that you have in SwiftUI. So here we have a VStack on line 13, which you may guess is short for vertical stack. If you look over at the UI on the right in the canvas, you'll see two items stacked vertically. If you change the V to an H, then you have a horizontal stack, and the items are now stacked next to each other. The Z stack allows you to organize items in front of or behind each other. So, I'll go back to VStack. For our calculator, we're going to lay out the buttons in a grid. So, one way to do that is by using the grid component. So, what I'm going to do is just below my text, so right here, line 17, I went down one new line. I'm going to create a grid. So…

Contents