
Swiftui Gestures
Implement advanced SwiftUI touch gestures—pinch-zoom, sequenced long-press drag, and UIKit interop—without fighting gesture composition bugs on iOS builds.
Install
npx skills add https://github.com/dpearson2699/swift-ios-skills --skill swiftui-gesturesWhat is this skill?
- Pinch-to-zoom with MagnifyGesture, clamped scale, double-tap reset, and spring animation
- Combined rotate + scale and drag-to-reorder list patterns
- Gesture velocity math and long-press-then-drag sequenced gestures with state enums
- SwiftUI + UIKit gesture interop for mixed stacks
- Dedicated accessibility considerations section alongside core APIs in SKILL.md
Adoption & trust: 1.7k installs on skills.sh; 713 GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Vercel React Native Skillsvercel-labs/agent-skills
Firebase Basicsfirebase/agent-skills
Building Native Uiexpo/skills
Firebase Ai Logic Basicsfirebase/agent-skills
Native Data Fetchingexpo/skills
Firebase Firestorefirebase/agent-skills
Journey fit
Common Questions / FAQ
Is Swiftui Gestures safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Swiftui Gestures
# Gesture Patterns — Advanced Reference Extended patterns for SwiftUI gesture handling. See the main `SKILL.md` for core APIs and common mistakes. ## Contents - [Pinch-to-Zoom with MagnifyGesture](#pinch-to-zoom-with-magnifygesture) - [Combined Rotate + Scale](#combined-rotate--scale) - [Drag-to-Reorder](#drag-to-reorder) - [Gesture Velocity Calculations](#gesture-velocity-calculations) - [Long-Press then Drag](#long-press-then-drag-sequenced-gesture-with-state-enum) - [SwiftUI + UIKit Gesture Interop](#swiftui--uikit-gesture-interop) - [Accessibility Considerations](#accessibility-considerations) ## Pinch-to-Zoom with MagnifyGesture Full implementation with clamped scale, double-tap reset, and smooth animation: ```swift struct PinchToZoomView: View { @State private var currentScale = 1.0 @State private var currentOffset = CGSize.zero @GestureState private var gestureScale = 1.0 @GestureState private var dragOffset = CGSize.zero private let minScale = 0.5 private let maxScale = 5.0 var body: some View { Image("photo") .resizable() .scaledToFit() .scaleEffect(currentScale * gestureScale) .offset( x: currentOffset.width + dragOffset.width, y: currentOffset.height + dragOffset.height ) .gesture(magnifyGesture) .simultaneousGesture(panGesture) .onTapGesture(count: 2) { withAnimation(.spring) { currentScale = 1.0 currentOffset = .zero } } } private var magnifyGesture: some Gesture { MagnifyGesture() .updating($gestureScale) { value, state, _ in state = value.magnification } .onEnded { value in let newScale = currentScale * value.magnification withAnimation(.spring) { currentScale = min(max(newScale, minScale), maxScale) } } } private var panGesture: some Gesture { DragGesture() .updating($dragOffset) { value, state, _ in guard currentScale > 1.0 else { return } state = value.translation } .onEnded { value in guard currentScale > 1.0 else { return } currentOffset.width += value.translation.width currentOffset.height += value.translation.height } } } ``` ## Combined Rotate + Scale Simultaneous rotation and magnification for image editing: ```swift struct RotateScaleView: View { @State private var currentAngle = Angle.zero @State private var currentScale = 1.0 @GestureState private var gestureAngle = Angle.zero @GestureState private var gestureScale = 1.0 var body: some View { Image("sticker") .resizable() .scaledToFit() .frame(width: 200, height: 200) .rotationEffect(currentAngle + gestureAngle) .scaleEffect(currentScale * gestureScale) .gesture( RotateGesture() .updating($gestureAngle) { value, state, _ in state = value.rotation } .onEnded { value in currentAngle += value.rotation } .simultaneously(with: MagnifyGesture() .updating($gestureScale) { value, state, _ in state = value.magnification } .onEnded { value in currentScale *= value.magnification currentScale = min(max(currentScale, 0.3), 5.0) } ) ) } } ``` ## Drag-to-Reorder Drag gesture with haptic feedbac