From the course: Make SwiftUI Playgrounds Applications
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Work with @Binding - Swift Tutorial
From the course: Make SwiftUI Playgrounds Applications
Work with @Binding
- [Instructor] We've successfully made buttons using state, but using state alone makes for some big chunky content views. We need to move state to sub views in the view hierarchy. Let's move the pizza size buttons to a new view to explore this. So I'm going to start here by creating a new file. Let's just go over here to code, and we're going to tap the button here for a new Swift file. We'll make a new Swift file in here and we're going to call this SizeView. So just tap in there, and change the name to SizeView. And then inside the code we'll type view and that'll give us the auto complete that will put all this stuff in place. So we just have to tap the return button, and now it'll ask us for a name for the struct and we're going to call it the same thing, SizeView. And sets that up, we can now go into the body. And then I'm going to delete that for right now. Go back up into content view and let's go find our button…
Contents
-
-
-
(Locked)
More on the view hierarchy12m 11s
-
(Locked)
Formatted numbers8m 23s
-
(Locked)
Computed properties6m 7s
-
(Locked)
Arrays9m 54s
-
(Locked)
For loops9m 42s
-
(Locked)
Use ForEach in SwiftUI8m 32s
-
(Locked)
Protocols, Hashable, and Identifiable3m 56s
-
(Locked)
Importing models and assets8m 27s
-
(Locked)
Adapting models8m 43s
-
(Locked)
Scroll view and list6m 34s
-
Work with @State and toggle buttons8m 43s
-
(Locked)
Make Button arrays7m 13s
-
(Locked)
Work with @Binding5m 59s
-
(Locked)
Enumeration types8m 45s
-
(Locked)
Selection from lists4m 21s
-
(Locked)
Optional values6m 10s
-
(Locked)
-