1

I am currently using the UISheetPresentationController in UIKit to show a sheet on top of a UIViewController to give additional information about the underlying UIViewController. The sheet will not block the interaction or dim the underlying UIViewController. The presented UISheetPresentationController will have a UICollectionView with multiple sections to display the additional information.

I would like to have a similar implementation like Apple Maps where the height of the smallest detent is aligned with the actual content of the presented sheet: Apple Maps Sheet displaying exactly the search bar

The smaller custom detent should have the same height than the first section of the UICollectionView in the presented sheet. Since the underlying view is a different UIViewController than the presented sheet it is difficult to create a custom detent that is exactly the same height as the content of the first section and would respond to any dynamic view changes.

The simplest solution that I came up with is to use a constant value for the detent height (e.g. 100) and then also use this constant value as a height restriction of the first section in the UICollectionView in the presented sheet. But using constant height variables could introduce issues when using a different font size and could therefore break the content of the first section of the UICollectionView. I would be interested if there is a better approach than manually aligning the heights of the sheet detent and the content of the sheet or if there are any best practices to achieve a similar behaviour like in Apple Maps.

  • Hello Philipp, I was just about to search a solution for the exact same problem. I also want my size to be dynamic, as my content depending on font sizes may change. How did you solve your problem? Would be awesome to hear! Cheers – Georg Aug 02 '23 at 07:11
  • 1
    Hi Gerog, unfortunately I did not yet find a better solution than the one described above. I will post it here once I found something better. – Philipp Woessner Aug 04 '23 at 09:20

0 Answers0