简体   繁体   English

SwiftUI:如何删除 LazyVGrid 内容中的水平填充?

[英]SwiftUI: how to remove horizontal padding in LazyVGrid content?

I have the following code:我有以下代码:

let gridItems = [GridItem(.adaptive(minimum: 300, maximum: 400), spacing: 10)]

ScrollView(.vertical, showsIndicators: false) {
    LazyVGrid(columns: gridItems) {
        ForEach(item) { i in
            HStack(spacing: 0) {
                Text("Testing")
                Spacer()
            }
            .border(.pink)
        }
    }
    .background(.green)
    .border(.blue)
}
.border(.red)

it draws this:它画了这个:

在此处输入图像描述

How can I remove the leading and trailing gap?如何消除领先和落后的差距? Where is that coming from?那是从哪里来的?

Adaptive item introduce width limitation:自适应项引入宽度限制:

let gridItems = [GridItem(.adaptive(minimum: 300, maximum: 400), spacing: 10)]
                                                  ^^^^^^^^^^^^ << here !!

in general internal grid spacing is configured as described in https://stackoverflow.com/a/63027052/12299030一般来说,内部网格间距的配置如https://stackoverflow.com/a/63027052/12299030中所述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM