我正在使用LazyVGrid
withSwiftUI
来显示 8 张图片。
从照片中可以看出,图像的尺寸并不统一,有些是精确的,有些比下一张照片的高度低..
我不明白为什么会发生这种情况..您有解决问题的想法吗?
这就是我创建LazyVGrid
LazyVGrid(columns: [GridItem(.adaptive(minimum: 160), spacing: 10)], spacing: 20) {
ForEach(productsItems) { product in
VStack {
Image(product.image)
.resizable()
.scaledToFill()
.cornerRadius(5)
.padding(5)
.background(
RoundedRectangle(cornerRadius: 5)
.stroke(.gray, lineWidth: 0.5)
)
}
}
}