user3721070
user3721070

Reputation: 151

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

Upvotes: 3

Views: 100

Answers (2)

Sahil Manchanda
Sahil Manchanda

Reputation: 10012

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.

Upvotes: 1

Aatish Molasi
Aatish Molasi

Reputation: 2186

I would recommend putting the buttons in a view and putting height and width constraints for the button relative to the superview.

You can add constraints to the view where the views leading trailing top and bottom are relative to the superview itself or updating it as the orientation changes.

Upvotes: 0

Related Questions