UISheetPresentationController in iOS swift

Updated 29 April 2022

Save

In this blog, we will see UISheetPresentationController. UISheetPresentationController manages the appearance and behavior of the sheet. Using this we can show our viewController as a sheet. In WWDC 2021 with the introduction of iOS 15, Apple also includes improvements to presenting sheets in UIKit with the new UISheetPresentationController.

Let’s see an example of it.

We have created a function sheet. There we have created an instance of our presenting ViewController. After that, we used the sheetPresentationController property. The detents accept an array. Here we have passed medium and large for the size of our ViewController. We have first used medium so our presenting ViewController will first appear in medium size. We have used the largestUndimmedDetentIdentifier property to add the dimming view. This would make the dimming view go away for a medium detent, and we can interact with the view underneath. We have used prefersScrollingExpandsWhenScrolledToEdge false To make the content scrollable in a medium detent. After that, we presented the view controller with the animated value true and completion nil.

Thanks for reading this blog.

You can also check other blogs from here. If you have any issues, queries, or suggestions then you can leave your issues/queries/suggestions in the comment section.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home