Search code examples
iosswiftswiftuiswipedraggesture

How can I disable iOS Reachability Swipe Gesture in SwiftUI


I am using the dragGesture in SwiftUI to develop my game. I am facing a problem with iOS Reachability Swipe Gesture. When user tries to swipe down at the very bottom of the device, iOS calls iOS reachability. I need to disable this iOS feature for my app. I checked this link:

Disable iOS Reachability Swipe Gesture in iOS game.

Below function seems to be the answer for UIKit:

override func preferredScreenEdgesDeferringSystemGestures() -> UIRectEdge {
    return [.bottom]
} 

How can I use this function and disable iOS Reachability Swipe Gesture in SwiftUI?


Solution

  • As Asperi Mentioned. SwiftUI have answer for this in iOS 16+.

    Apple documentation

    in my case I just add

    .defersSystemGestures(on: bottom)