[英]Combining DragGesture and MagnificationGesture on a SwiftUI View in iOS14
[英]Simultaneous MagnificationGesture and DragGesture with SwiftUI
Apple Maps 應用程序允許同時進行兩指拖動和放大。 我試過用 SwiftUI手勢來實現這個功能。 同時旋轉和放大按預期工作,但同時拖動和放大不能。 也許有一種方法可以使自定義行為符合Gesture 協議?
我無法同時實現拖動和放大。 根據我的經驗,DragGesture 只能在一次觸摸時工作,並在屏幕上有兩次觸摸時結束。 我似乎在 SwiftUI 中只有需要相同數量的觸摸的手勢才能同時進行。 也無法直接訪問觸摸事件來實現自定義手勢識別器。 希望這在未來會有所改變。
我有同樣的問題。 查看此解決方案 --> https://betterprogramming.pub/gestures-in-swiftui-e94b784ecc7
他使用:“同時”
.gesture(MagnificationGesture()
.onChanged { value in
self.magnificationValue = value
}
.simultaneously(with: RotationGesture().onChanged { value in
self.rotationValue = value
}))
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.