我需要找出我的ScrollView
停止移动的确切时刻。 SwiftUI能做到吗?
这里是相当于UIScrollView
的解决方案。
经过思考,我一无所知...
一个用于测试的示例项目:
struct ContentView: View {
var body: some View {
ScrollView {
VStack(spacing: 20) {
ForEach(0...100, id: \.self) { i in
Rectangle()
.frame(width: 200, height: 100)
.foregroundColor(.green)
.overlay(Text("\(i)"))
}
}
.frame(maxWidth: .infinity)
}
}
}
感谢!
print
从未被调用。此外,使用额外的手势来检测它何时开始,可以这样做:.simultaneousGesture( DragGesture().onChanged({ _ in print("Started Scrolling") }))
- Oleg G.ViewOffsetKey
的实现是什么? - Oleg G.Started scrolling
被调用了,但是stop
没有被调用。 - Oleg G.