Custom ViewController height for UIPresentationController

Hi all,


I’m trying to create a custom presentationcontroller, but I’m having the following issue.

The view controller that is presented, should slide in from the bottom and only cover a part of the screen (like the Apple Pay sheet in iOS11), but in my case the height of the view controller that will be shown is dynamic.

When you implement a presentationcontroller, you override the

frameOfPresentedViewInContainerView
property.

In my case I have this:


override var frameOfPresentedViewInContainerView: CGRect {
    
        var newFrame = CGRect.zero
       
        if let width = containerView?.bounds.width, let height = containerView?.bounds.height {
            newFrame.origin = CGPoint(x: 0, y: height - 100)
            newFrame.size = CGSize(width: width, height: 100)
        }
       
       
        return newFrame
       
    }


But I want to get rid of the

height: 100
, (on line 7) this has to be dynamic. But I can’t seem to find a way to get the calculated AutoLayout height of my presented viewcontroller.

Anyone who know how to do this?


This is a screenshot of what I'm trying to do => https://www.dropbox.com/s/9s8odfy6hjnnnrx/Screen_Shot_2017_06_05_at_3.58.50_PM.png?dl=0


Kind regards, and thanks in advance.

Did you manage to find a solution for that issue? I am looking for one as well, can't seem to find a proper way to handle this task.

I'm assuming the original asker probably found an answer since this post/question is 3 years old now. However, I was looking for an answer for this very thing myself and was a little bummed at first when I didn't see any answers here. I kept searching and came across two extremely helpful articles. I want to share in case anyone else is looking as well and comes across this question.

  1. Daniel Gauthier's Custom Transitions Blog Post:
    • https://danielgauthier.me/2020/03/03/vctransitions3.html
  2. The above article mentions this blog post by Kyle Bashour on Custom View Controller Transitions as being a huge help:
    • https://kylebashour.com/posts/custom-view-controller-presentation-tips

Good luck and happy coding!

Custom ViewController height for UIPresentationController
 
 
Q