【发布时间】:2020-12-23 12:36:16
【问题描述】:
预期目标是扩展高度以显示其所有元素(无滚动)的视图,可以允许拖放其元素以重新排序它们。我相信 SwiftUI 列表将支持这种拖放行为,但是当与其他元素一起放置在 VStack 中时,它会将其高度限制为一个元素的大小。我认为这些列表视图不打算在另一个视图中使用?
List {
ForEach(viewModel.sections, id: \.self) { section in
HStack {
Text(section.localisedString)
Spacer()
Image(systemName: "line.horizontal.3")
.foregroundColor(ColourPalette.bodyText)
.smallIcon()
}
.background(ColourPalette.background)
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
}
.background(ColourPalette.background)
}
.listStyle(PlainListStyle())
.background(ColourPalette.background)
我也想隐藏分隔符,但这似乎是 SwiftUI 的持续挣扎,但即使是 SideBarListStyle() 也不适合我。
使用VStack() 是否更有意义?如果是这样,实现拖放和经典列表侧栏项目的重新排序有多容易?
【问题讨论】:
-
也许在
List中使用Section和header或footer可以解决您的问题
标签: swiftui swiftui-list