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
From the course: Programming for Non-programmers: iOS 17 and Swift 5
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
SwiftUI layout basics2m 57s
-
(Locked)
Creating custom SwiftUI components1m 57s
-
(Locked)
Creating calculator buttons4m 50s
-
(Locked)
Setting button text2m 41s
-
(Locked)
Setting button width2m 33s
-
(Locked)
Setting button colors2m 2s
-
(Locked)
Challenge: Create the value text view1m
-
(Locked)
Solution: Create the value text view4m 16s
-
(Locked)
-
-
-
-