Search code examples
iosautolayout

Autolayout issue AlignParentBottom


enter image description hereThis is my first time to use autolayout in iOS and I'm facing a small issue. The thing I'm trying to implement is to have a UIView as a content view and in the footer there should be a UIImageView, the UIView should have a dynamic height where it covers the full view controller till it reaches the UIImageView at the bottom. I have gone through multiple scenarios but none of them worked.

Something similar to LinearLayout with vertical alignment in Android and AlignParentBottom=true for the UIImageView.

Your help is appreciated.

Regards,


Solution

  • If I understand correctly, you want a UIView stacked over a UIImageView as shown in the image below.

    View Layout

    1. Lay the views more or less how you want them
    2. Add leading, trailing, top, and bottom constraints to the image view (footer) so that it stays stuck to the bottom and resizes it's width. Add also an aspect ratio constraint. enter image description here

    3. Add leading, trailing, top, and bottom constraints to the UIView.

    enter image description here

    You should be good to go.

    EDIT

    After looking at how you set up your constraints, it seems they are wrong. I've added the constraints above for reference. Just tested it and worked like a charm on iPad.