From the course: Complete Guide to SwiftUI
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
ViewBuilder
- [Instructor] With modifiers, we can add formatting to a view. But what if we could make customized views? To some extent, we can already. External views like Menu Row View and Order Row view do this; however, they have limits. Let's head over to Menu Row View, which we got right here. One thing that we can actually do is make a variable out of our view. For example, let me go above the body here and let's go var ratingsView. And I'm going to make that a RatingsView and it'll be a RatingsView. It's rating:item.rating. And now I can use ratings view here in my code without having a lot of parameters running around in the body of the code here. So I can just change this to ratings view. So it cleans up the code very nicely by doing this. Now try this same thing with the name and price, however. So let's go make another one here. Var namePriceView. And this time it's not one or the other, so I want to make it a view.…
Contents
-
-
-
-
-
-
-
-
-
-
-
-
-
- (Locked) Extensions5m 14s
- (Locked) Custom modifiers3m 53s
- (Locked) More modifiers2m 33s
- (Locked) Modifiers with parameters5m 13s
- (Locked) Shapes6m 11s
- (Locked) Modifiers with added views5m 19s
- (Locked) ViewBuilder3m
- (Locked) Conditional ViewBuilder3m 40s
- (Locked) Challenge: Make Home a back button29s
- (Locked) Solution: Make Home a back button5m 36s
- (Locked)
-
-
-
-