Skip to content

Create a Detent with a Custom Height in iOS 16

Adding a custom detent height in iOS 16 is trivially easy.

Stuart Breckenridge
Stuart Breckenridge
1 min read
Create a Detent with a Custom Height in iOS 16

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.

In iOS 15:

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()]
📱App Development🧑🏻‍💻 Code