Maruf
Maruf

Reputation: 33

How to create different layout for iPhone and iPad using Autolayout?

I'am creating a UI for both iPhone and iPad using "Vary for Traits". But I'am getting confuse when to choose Width or Height.What happen when I select Width or height or both

Upvotes: 1

Views: 3054

Answers (1)

matt
matt

Reputation: 535988

It will really help to know what the size class constraints mean. See my https://stackoverflow.com/a/52317547/341994 for a summary.

Okay, so what the checkboxes mean depends on what the current traits are for the storyboard you're looking at.

  • First set the device type you want to design constraints for, on the left. Now you will see some size classes. If you chose an iPad, the size classes are wR hR. That is width Regular and height Regular.

  • So now click Vary for Traits. You are about to design some constraints. Which size classes are you about to design? Compare that to what we just said. If width should be Regular click Width. If height should be Regular click Height.

So for example if you chose an iPad on the left (wR hR) and you now click both Width and Height, that means Regular Regular, which means “I am about to design for iPad.”

But if you chose a small iPhone in portrait on the left (wC hR) you might now click just Width, which means Compact Any, because you don’t care about the height constraint; you just want Compact Width which means “I am about to design for a small iPhone in any orientation.”

Upvotes: 3

Related Questions