This provides flexible stack layout in SwiftUI.
MIT License
This provides flexible stack layout in SwiftUI.
Optimizes the arrangement of items according to the aspect ratio of the parent view.
Optimize the arrangement of items according to the number of them.
struct ContentView: View {
let colors: [Color] = [.blue, .red, .green, .orange]
var body: some View {
FlexibleVStack {
ForEach(colors.indices, id: \.self) { index in
Rectangle()
.foregroundStyle(colors[index])
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
.padding()
}
}