我有全屏元素列表。
VStack{
List {
ForEach(books, id: \.id) { book in
Text(book.title)
.background(Color.yellow) // text background
.listRowBackground(Color.blue) // cell background
}
.frame(height: UIScreen.main.bounds.height)
}
}
.background(Color.red)
.edgesIgnoringSafeArea(.all)
滚动时有可能在顶部捕捉每个单元格吗?我不知道如何做到这一点。
谢谢大家!
1条答案
按热度按时间qojgxg4l1#
可以使用
DragGesture
和ScrollViewReader
在SwiftUI中创建捕捉列表。我们在计算移动列表的速度。
下面是一个完整的示例代码: