From the course: iOS 14 Development Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Making a custom SwiftUI view
From the course: iOS 14 Development Essential Training
Making a custom SwiftUI view
- [Instructor] At this point in our app we've only used the built-in SwiftUI components HStack, VStack, Circle, Slider, et cetera. But you can actually create your own UI components that gives you the benefit of being able to reuse them and to make your code more readable. Let's take a look at how that might work by making this circle here into its own SwiftUI view. Press Command + N to create a new file and go to iOS user interface, SwiftUI View, and hit Next. Now save this file as ColorSwatch and then hit Return to create the file. So we have this ColorSwatch right here and we have the text that says "Hello, World." So, now we can actually go back and our content view and let's say, I go in my HStack here, I can create a ColorSwatch just like that. You type ColorSwatch just as you typed it in your file name, and it adds that to your view. So if I hit resume right here, it's not going to look very pretty but you'll see…
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)
Getting text input with SwiftUI4m 45s
-
(Locked)
Using a slider in SwiftUI5m 26s
-
(Locked)
Creating a slider with a color swatch2m 38s
-
(Locked)
Making a custom SwiftUI view5m 22s
-
(Locked)
Creating a reusable slider component4m 54s
-
(Locked)
Increasing reusability in custom views3m 13s
-
(Locked)
Challenge: Build a color picker app1m 19s
-
(Locked)
Solution: Build a color picker app1m 17s
-
(Locked)
-
-