Skip to main content

swiftui-gesture | ios-app-dev-memo

Gesture いろいろ

onTapGesture で範囲指定

swift
.onTapGesture { location in
let rh = location.y / geom.size.height
let rw = location.x / geom.size.width

if rw < 0.2 {
print("左端")
}
}

DragGesture

swift
.gesture(
DragGesture()
.onEnded { gesture in
if gesture.translation.width < 0 {
print("左スワイプ")
}
}