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 - Swift Tutorial
From the course: Make SwiftUI Playgrounds Applications
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
-
-
-
(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)
-