# PresentationController with AutoLayout

**URL:** <https://forums.kodeco.com/t/presentationcontroller-with-autolayout/35260>\
**Category:** Swift\
**Created:** [October 5, 2017, 8:54pm UTC](https://forums.kodeco.com/t/presentationcontroller-with-autolayout/35260 "2017-10-05T20:54:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thenerd\_be](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/thenerd_be/32/106627_2.png) [@thenerd\_be](https://forums.kodeco.com/u/thenerd_be)\
**Post date:** [October 5, 2017, 8:54pm UTC](https://forums.kodeco.com/t/presentationcontroller-with-autolayout/35260/1 "2017-10-05T20:54:57Z")

</div>

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?

 ![50_PM](https://raywenderlich-com-v3-forums.s3.amazonaws.com/original/3X/4/a/4af24657b1d0a1494795d1a534348479b859f30f.jpg)

Thanks a lot in advance.

---

<div class="post-metadata">

**Author:** ![syedfa](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/syedfa/32/101500_2.png) [@syedfa](https://forums.kodeco.com/u/syedfa)\
**Post date:** [October 6, 2017, 1:36am UTC](https://forums.kodeco.com/t/presentationcontroller-with-autolayout/35260/2 "2017-10-06T01:36:47Z")

</div>

@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](https://developer.apple.com/documentation/uikit/uialertcontroller) to the documentation from Apple’s website. Hopefully this will point you in the right direction, and make your task easier. 🙂

I hope this helps!

All the best!

---

<div class="post-metadata">

**Author:** ![thenerd\_be](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/thenerd_be/32/106627_2.png) [@thenerd\_be](https://forums.kodeco.com/u/thenerd_be)\
**Post date:** [October 6, 2017, 6:34am UTC](https://forums.kodeco.com/t/presentationcontroller-with-autolayout/35260/3 "2017-10-06T06:34:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@system](https://forums.kodeco.com/u/system)\
**Post date:** [March 21, 2018, 1:09pm UTC](https://forums.kodeco.com/t/presentationcontroller-with-autolayout/35260/4 "2018-03-21T13:09:06Z")

</div>

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