From the course: Make SwiftUI Playgrounds Applications

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

Make Button arrays

Make Button arrays

- [Instructor] Your first button was a toggle but buttons have a lot more uses than that. For example, selecting multiple items such as the size of a pizza uses a series of buttons. Let's build a pizza size control to give us the size of the pizza. Now, pizza sizes are more model than view. We right now have this function pizzaSize here in content view. So I think it's a better idea to move it into the menuItem file. And we're going to rename it pizzaSizeText. So let's start here by just selecting it, and I'm going to cut it, then hop on over here to menuItem, and I'll put it on top just above menuItem and just tap again, hit Paste. And we're going to change this to pizzaSizeText, like that. And you'll see we get a whole bunch of errors because that's actually changed a bunch of other stuff but we'll get to that in a little bit. Now we're going to set some discreet values for small, medium, large, and extra large here.…

Contents