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.
Creating custom SwiftUI components
From the course: Programming for Non-programmers: iOS 17 and Swift 5
Creating custom SwiftUI components
- [Instructor] So while we have our ButtonGrid here, it's actually starting to get a little bit crowded inside of our content view. So what I want to do is take this whole grid and put it in its own custom view that we call ButtonGrid, and then that file can have only ButtonGrid related things in it. So let's look at how to do that. The first step is to press command N on the keyboard or create a new file through the file menu. And what we want to do is create under iOS and user interface a SwiftUI View. So choose that and hit next. I'm going to save it in the default location and just as I said a second ago, let's name it ButtonGrid, capital B, capital G, and then I'll hit return to create it. I'm instantly taken to my ButtonGrid, so it's a new tab over here. If you aren't taken there automatically, just open up the project navigator and click on it. So I'll close the project navigator. And what we want to do is replace this text, Hello, World, with our ButtonGrid. So let's go over…
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)
-
-
-
-