[SwiftUI] DragGesture의 방향에 따라 분기하기
DragGesture를 컨트롤할 때 해당 Drag의 방향에 따라서 액션을 분기하기 위해서DragGesture.Value의 location값과 startLocation 값을 활용했다.
코드
다음의 코드에서 onEnded 함수 내에서 DragGesture.Value 값을 gesture로 받아온 뒤 location.x의 값과 startLocation.x의 값을 비교하여 방향을 구분하여 분기처리할 수 있다.
import SwiftUI
struct ...
studio-pendant.hashnode.dev1 min read