07 Jun 2022
•
1 min read
Create a Detent with a Custom Height in iOS 16
Adding a custom detent height in iOS 16 is trivially easy.

Prior to iOS 16, UISheetPresentationController
only supported two detents: medium
and large
. With iOS 16, we can now create our own detent with a custom height.
sheetPresentationController?.detents = [.medium(), .large()]
In iOS 16, create a detent identifier and then create a detent with that identifier and provide a maximum height.
let smallId = UISheetPresentationController.Detent.Identifier("small")
let smallDetent = UISheetPresentationController.Detent.custom(identifier: smallId) { context in
return 80
}
sheetPresentationController?.detents = [smallDetent, .medium(), .large()]
Discussion