PresentationController with AutoLayout

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 now 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, 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?

Thanks a lot in advance.

1 Like

@thenerd_be Thanks very much for your question! It seems like rather than trying to implement a ViewController, you’re looking to implement an AlertController, of type ActionSheet. This is better suited for your needs. Here is a link to the documentation from Apple’s website. Hopefully this will point you in the right direction, and make your task easier. :slight_smile:

I hope this helps!

All the best!

Hi, thanks for your answer.
I can’t use an actionsheet as I have to implement a custom design.

This topic was automatically closed after 166 days. New replies are no longer allowed.