【发布时间】:2021-02-16 09:47:58
【问题描述】:
我是 SwiftUI 的新手
我正在尝试像这样创建我的部分,其中每一行都相互分隔。有点像背景没有相互连接的部分。看图:(图来自dribbble)
但我的结局是这样的: (我创建了背景蓝色,以便大家可以清楚地看到行)
这是我的代码:
import SwiftUI
struct ProductPageView: View {
init() {
UITableView.appearance().backgroundColor = .clear // Uses UIColor
}
var body: some View {
NavigationView {
ZStack {
Color.blue.edgesIgnoringSafeArea(.all)
VStack {
List {
ForEach(arrayProduct, id: \.name) { dataProduct in
ProductListCell(item: dataProduct)
}
.listRowInsets(EdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10))
}
.listStyle(InsetGroupedListStyle())
}
}
.navigationTitle("Produk")
}
}
}
我用过listRowInsets,但它只是拉伸它。
如何在行之间创建这种分隔?
任何帮助将不胜感激。
谢谢
【问题讨论】:
-
它们是insets,所以试试负值。
-
喜欢
.listRowInsets(EdgeInsets(top: -10, leading: 0, bottom: -10, trailing: 0))?没用的人
标签: ios list swiftui uikit row