且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在SwiftUI中向ScrollView内部的View添加拖动手势会阻止滚动

更新时间:2023-11-18 14:10:28

您可以将minimumDistance设置为某个值(例如30).然后,仅当您水平拖动并达到最小距离时,该拖动才起作用,否则,滚动视图或列表手势会覆盖视图手势

You can set minimumDistance to some value (for instance 30). Then the drag only works when you drag horizontally and reach the minimum distance, otherwise the scrollview or list gesture override the view gesture

.gesture(DragGesture(minimumDistance: 30, coordinateSpace: .local)