drag-and-drop - 如何使用列表视图在 swiftUI 中创建两列列表?
问题描述
我是 SwiftUI 的新手。我需要创建一个显示在两列中的列表。它更有可能是每行有两个项目的 collectionView。条件是我需要使用“列表”创建它,因为我需要在此列表中添加“拖放以重新排序”功能。
到目前为止,我已经使用 HStack 和 VStack 实现了它,但在这种情况下,没有选项可以拖动和重新排序列表。
这是我到目前为止所做的代码:
ZStack{
Button(action: {
}) {
HStack{
Image(systemName: "person.crop.circle.fill")
Text(font)
.font(.system(size: 13 ))
.foregroundColor(.black)
.frame(minWidth: UIScreen.main.bounds.size.width/4, maxWidth: UIScreen.main.bounds.size.width/4)
.padding(.horizontal)
}
.padding(10)
}
.foregroundColor(Color.black)
.background(Color.white)
.cornerRadius(8)
.background(
RoundedRectangle(cornerRadius: 5)
.fill(Color.white)
.shadow(color: .gray, radius: 2, x: 0, y: 2)
)
}
我的问题是:如何在 SwiftUI Using List 中创建两列列表的集合视图类型?如果我使用 HStack 和 Stack 的实现听起来不错,那么:有没有办法实现拖放以重新排序列表功能?
我无法使用 LazyVGrid,因为我的要求是 ios13。
任何帮助将不胜感激。
谢谢!!
更新:我使用 swiftui 中的 UIViewRepresentable 包装的 UICollectionView 解决了它。
解决方案
推荐阅读
- php - 如何在 TCPDF 中插入标题徽标?
- sql-server - T-SQL 查询以获得所需的输出
- node.js - nixos中的nodejs headless-gl null
- python - 单击一个按钮以将输入字段保存在 Tkinter 中的 csv 文件中
- css - 在 hr 上对齐文本基线
- razor-pages - 使用 AddRazorRuntimeCompilation 时出现 CSS 隔离问题
- javascript - supbase 下载图像错误请求标头应具有必需的属性“授权”
- java - 如何检测用户是否输入分数
- java - 从 Gradle 中的依赖项中排除特定包
- rust - 是否可以从同一结构中展平多个排水迭代器?