How to create a Responsive Grid View in SwiftUI Tutorial (iOS 2022)

preview_player
Показать описание
In today's video we will be looking at how we can create our very own personalised and responsive Grid View. It's a very powerful feature in SwiftUI that can help you adapt your list to any screen size.

Рекомендации по теме
Комментарии
Автор

Excellent and very clear explanation . Thank you very much

ndrukz
Автор

It was veru clear about the three alternatives. That was just what I needed today.

BruceCichowlas
Автор

I love you! You definitely just saved my grade

hmalill
Автор

Don't usually comment - But just some constructive thoughts;

Although you did a good job creating the grid and showing the viewers how it is done; I found that there was no explanation as to 'why' or 'what' everything actually is.
For example, you could explain as to why you are using LazyVGrid or what 'adaptiveColumns' actually does (Rather than "It just works")


Other than that, good demonstration of how to create a grid, would have preferred a few more minutes of explanation on-top though :)

All the best

officiallynebula
Автор

I notice that you often use absolute value. I'm new in mobile phone development so I don't know if it's a good thing but isn't it better to have relative values depending directly of the size of the screen ?

etesvgz
Автор

You are a great sir IAM from India 🇮🇳🇮🇳🇮🇳<keep it>

rishabh
Автор

You can achieve true dynamic height width by using GeometryReader
//Example
private let numberOfColumn = [
GridItem(.flexible()),
GridItem(.flexible()),
GridItem(.flexible()),
]

ScrollView(.vertical, showsIndicators: false) {
VStack {
GeometryReader { geometry in
LazyVGrid(columns: numberOfColumn, spacing: 20) {
ForEach(gridItems, id: \.self) { fav in
Rectangle()
.frame(width: geometry.size.width / CGFloat(numberOfColumn.count), height: geometry.size.width /
.foregroundColor(.red)
}
}
}
}
}

Zainanjum