How can I disable iOS Reachability Swipe Gesture in SwiftUI

Viewed 269

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?

1 Answers

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

Apple documentation

in my case I just add

.defersSystemGestures(on: bottom)
Related