skip to Main Content

When presenting a UIViewController modally after iOS 13, the presentingViewController gets pushed down to also look like a view in the stack like seen in this image:

Standard Modal Presentation

But in Apple Maps, for example, this does not happen. The presentingViewController stays full screen:

Apple Maps Modal Presentation

I would like to achive the same modal presentation style as in Apple Maps. Has anyone got this working?

I have obviously searched stack overflow and the entire web, looked at every property on UIViewController and UISheetPresentationController, tried setting the modalPresentationStyle of the presentingViewController to fullScreen and overFullScreen (which I rightly assumed before trying wouldn’t work).

2

Answers


  1. Chosen as BEST ANSWER

    The correct answer to this question sadly seems to be that there is no way to do this without either completely reimplementing UISheetPresentationController or presenting it on another UIWindow.

    Thanks to @HangarRash, I found out that there is a workaround that works 90% of the time though: Instead of adding the .large() detent, adding a detent with a ever so slightly smaller value makes the view look like it does in Apple Maps:

    UISheetPresentationController.Detent.custom(identifier: "almostLarge") { context in
        return context.maximumDetentValue - 0.1
    }
    

    The only downside to this is that it does not solve the unwanted UI behaviour when a text input is selected inside of the sheet. For the span of time where it is selected only, the sheets will look like they do in my first image again.


  2. If you try to present myViewController try to put this before navigationController.preset:

    myViewController.modalPresentationStyle = .fullScreen
    

    This shoud present your VC on full screen.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search