SwiftUI 中的自定网格项

Moj*_*ini 6 grid layout sizing swiftui

我已经使用adaptiveflexibleminimum没有运气的大小。

struct ContentView: View {

    let rows = [
        GridItem(.adaptive(minimum: 80)) // lowering this cuases an unwanted shrink of text.
    ]

    var body: some View {
        LazyVGrid(columns: rows, spacing: 8) {
            ForEach((0...10), id: \.self) { item in
                Text("\(Int.random(in: 0...50000))")
                    .background(Color.yellow)
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

结果:

结果

如您所见,似乎它以minimum大小为单位fixed!另外,请注意,我不知道最小尺寸,因为它Text是自行调整尺寸的。

我们如何为LazyVGridor提供自定尺码的项目LazyHGrid

我希望它看起来像一个标签视图。