From the course: iOS Development Tips

Unlock this course with a free trial

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

Collection views for SwiftUI

Collection views for SwiftUI

From the course: iOS Development Tips

Collection views for SwiftUI

- [Instructor] The most asked for view in SwiftUI was a collection view in iOS 14. We got them in the form of lazy grids. Now I have a simple VStack for my exercise files here. With a ForEach each listing all of my menu items. I can scroll through all of these, but it's not the best use of screen real estate. So let's go ahead and do that and try it out. So you can see that I just have a lot of space. And I get good pictures, but it's just not using things as well as I could. Now a grid of two columns would make this a lot better 'cause I'd have of my 10 pizzas, I'd probably have two columns of five. That would probably fit too. So I'm going to use a LazyVGrid to do that. Now how do you go about making the LazyVGrid? Well, it's got a number of columns. These can be different sizes if you wish. We define them as an array of grid items. So I'm going to go up to the top of my content code here. And I'm going to add a constant…

Contents