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,800 courses taught by industry experts.
Solution: Create the value text view
From the course: Programming for Non-programmers: iOS 17 and Swift 5
Solution: Create the value text view
- [Instructor] Here is my solution to the chapter's challenge. And I want to point out that the goal for the challenge is not to match my code, it's to satisfy the requirements of the challenge. So if you got there in any way, that means you passed. With that said, let's go over to the content view. And here we have some text that says, hi everybody, above the button grid. So the content view represents what your whole app is going to look like. So what we want here is to have some text that displays the total in the calculator. Usually, that text is right aligned. So to do that, I'm going to create a custom SwiftUI view with Command + N. I'll choose iOS, SwiftUI View, and hit Next or return. We'll name this TotalText and then hit Return or Create. So now I have my TotalText view open, and what I'm going to do here is create a variable just at the end of line 10. I'll just make a new line and we're going to call this value and set it equal to the string zero. Now, inside of our text…
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)
-
-
-
-