UIPresentationController multiple sizes or detents

2.3k Views Asked by At

I am working on trying to implement a presentation controller that essentially mimics the behavior of the UISheetPresentationController. I am doing this because I want to add a third detent and also I want this to work for iOS 14, so I cannot use the existing UISheetPresentationController.

I have it where I can present a view controller and it will stop at one location (say 50% of the screen height). And then I have a pan gesture that, when active, starts the interactive dismissal of the view controller. If the view controller is pulled down so far when the gesture ends, the view is dismissed, otherwise the dismissal is cancelled and the view returns to the 50% height.

That is all working fine. But then how do I add multiple stops, or detents? The pan gesture starts an interactive dismissal, but that dismissal does not support multiple different places where the view controller could end up.

Does anyone know how Apple implements their "detents" in the UISheetPresentationController? Or does anyone have any suggestions on how this might be implemented?

1

There are 1 best solutions below

0
On

You can also add this to your .sheet{}

.presentationDetents([.medium, .large, .fraction(0.1)])

or

.presentationDetents([.medium, .large, .height(300)])