iosswiftswiftui

Restrict sheet dismissing by swipe down in swiftui


I have a button and when I click on it a new View will present as a sheet. In SwiftUI by default swipe down gesture will dismiss the sheet view. I want to restrict it.

I'll have a button for dismissing. Until I press that button sheet should not get dismissed.


Solution

  • If you are using swiftUI, you may find this useful

    https://github.com/egeniq/BetterSheet

    It has the feature you want.

    ---Edited---

    Revisit the problem after months. If you don't want extra library, https://stackoverflow.com/a/61239704/10800901 would serve you well. Very elegant solution. Work like a charm.