23

Apple has finally released an Apple Maps-style "bottom sheet" control in iOS 15 in 2021: UISheetPresentationController.

This type of sheet natively supports "detents", the heights at which a sheet naturally rests. The default large() detent represents a full-screen sheet presentation, whereas the medium() detent covers approximately half the screen.

However, there is no small() detent in the API.

Apple Maps and similar apps typically show a small fully-collapsed sheet at the bottom of the screen, which can be dragged to half-height, which can be dragged to full-screen. Apple Maps actually shows a 1/3rd height screen, which appears to be different than the medium() detent.

Apple Maps Small Collapsed Bottom Sheet

Using UISheetPresentationController, not any 3rd-party reimplementation of bottom sheets, how can a sheet be presented with an Apple Maps-style collapsed small detent at the bottom of the screen?

pkamb
  • 30,595
  • 22
  • 143
  • 179
  • 5
    > FB9147171 - Add `small()` collapsed Detent to UISheetPresentationController – pkamb Jun 09 '21 at 16:50
  • 11
    A `custom(Double)` option where you can specify a custom height would also be super useful! – Vin Gazoil Jun 11 '21 at 10:41
  • 1
    My thoughts exactly. The way the API is designed and even how they described usage in the WWDC videos makes me think they’ll add support for .collapsed() or .small() in a future release. I’d also love to figure out how to support the Find My style UI where the sheet sits on top of the tab bar. – Kyle Clegg Oct 21 '21 at 10:06
  • 1
    Also if you look at the stocks app there’s actually a variant of the large style detent that allows for a little extra space where they display scrolling stock tickers. Some customization options to support creative interfaces like this would be highly welcomed. – Kyle Clegg Oct 21 '21 at 10:08

2 Answers2

12

I filed a radar to ask for support. I suggest anyone else who wants to see this does the same. Realistically medium and large won't cut it and we'll be relying on third party libs still if this doesn't get added before iOS 15 is released.

BinaryGuy
  • 1,215
  • 1
  • 15
  • 29
5

Use +[UISheetPresentationControllerDetent _detentWithIdentifier:constant:].

It's a private method.

Sample

 Summary: UIKitCore`+[UISheetPresentationControllerDetent _detentWithIdentifier:constant:]        Address: UIKitCore[0x00000001838d50fc] (UIKitCore.__TEXT.__text + 17876312)
Jinwoo Kim
  • 51
  • 2
  • 3