Is it possible to have a new SwiftUI List with 2 columns? I'm trying to replicate on iOS the Library
view from the podcasts app and it looks to be impossible...
Refreshable lists with 2 columns
If you define a HStack in the List, you should get the effect
ForEach (0..<10, id: \.self) { index in
HStack {
Text("Hello")
.frame(width: 200, height: 20, alignment: .center)
Text("\(index)")
.frame(width: 200, height: 20, alignment: .center)
}
}
Have you considered using a LazyVGrid
? You can specify the number of columns and it should grow vertically as needed.
https://developer.apple.com/documentation/swiftui/lazyvgrid
It looks like the LazyVGrid
is what I need to have for the columns, unfortunately the refreshable
modifier is not working. Is it a bug or the refreshable
modifier is available only on lists?
this is my implementation so far 😃
ScrollView {
LazyVGrid(columns: columns) {
ForEach(self.model.data) { feature in
FeatureRow(feature: feature, cover: feature.firstPicture)
}
}
}.refreshable {
self.load()
}
.onAppear {
self.load()
}
What happens if you move the refreshable modifier to be inside one level so it’s right after the LazyVGrid
and not after the ScrollView
?
If that doesn’t work, could you file a feedback assistant for this and share the number with me?