Search code examples
iosautolayout

How to adjust the constraints for portrait and landscape view?


I have 3 simple buttons, how can I adjust the constraints for portrait and landscape view like below?

Portrait:

enter image description here

Landscape:

enter image description here


Solution

  • I would put these buttons under a stackview and set constraints as below

    enter image description here

    The Multipler for both height and width is set to 0.8 i.e. 80% of the dimension. And the distribution of stackview to Fill Equally. This would result in :

    Portrait

    enter image description here

    Landscape

    enter image description here

    With Align center to X & Y of Superview. They will always be centered.