[英]how to remove bottom space of list view on swiftui
I want to remove the empty space below list element.我想删除列表元素下方的空白区域。 Height has to be dynamic for list rows.
列表行的高度必须是动态的。 If I remove the list, then the content will start from the bottom.
如果我删除列表,那么内容将从底部开始。
Here is code:这是代码:
var body: some View {
VStack{
Spacer()
HStack{
Text(orderDetails.orderNumber ?? "").bold()
Spacer()
}
List{
Section(header: ListHeader()) {
ForEach(paidDetails.indices,id:\.self) { i in
HStack {
Text("Paid By:")
Spacer()
Text(paidDetails[i].name ?? "")
Spacer()
Text((paidDetails[i].amountCollected))
}
}
}
}
Button(action: {
presentationMode.wrappedValue.dismiss()
}, label: {
Text("Close".localized).bold()
})
.background(Color("CallCustomerBG"))
}
}
}
You can add that button to the section footer like so:您可以将该按钮添加到部分页脚,如下所示:
Section(header: ListHeader(), footer: {
Button(action: {
presentationMode.wrappedValue.dismiss()
}, label: {
Text("Close".localized).bold()
})
.background(Color("CallCustomerBG"))
}) {
ForEach(paidDetails.indices,id:\.self) { i in
HStack {
Text("Paid By:")
Spacer()
Text(paidDetails[i].name ?? "")
Spacer()
Text((paidDetails[i].amountCollected))
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.