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

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