I want a view to have width 0.4 screen width in landscape and 0.5 screen width in portrait.
So I have tried "vary for traits". I selected wC hR and set 0.5 and clicked "done". Then I selected wR hR and set 0.4 as shown:
Yet both size classes still show as 0.4.
I have also tried setting the constraints using "view as ...(wC hR) etc. without using vary for constraints.
I have also tried adding a separate size class in the box shown, but with no success.
“Auto Layout is a system that lets you lay out your app's user interface by creating a mathematical description of the relationships between the elements. You define these relationships in terms of constraints either on individual elements, or between sets of elements.”
Size classes help you change the layout of views to adapt to various screen sizes, ranging from a tiny iPhone SE to a massive 12.9” iPad Pro. There are 3 different cases for a size class: regular , compact , and unspecified .
Width size class doesn't always change with the orientation - not on every device.
For example, only on the Plus devices the landscape becomes Regular width, but on other devices it's always compact.
However, the height size class changes on any iPhones (not iPads):
hR
- for portrait and hC
- for landscape.The illustrations on this page should give you more understanding how they work: http://useyourloaf.com/blog/size-classes/
Since there is no option to change the multiplier for different size classes, you need to create two constraints, and set conditions for Installed
.
This one for landscape:
And for portrait:
In I phones - 2 types size -
1. portrait mode - wC hR Landscape mode - wC hC
2. portrait mode - wC hR Landscape mode - wR hC
Steps 1.- Select 6s device portrait mode in scene : give the constraint 0.5 screen width. elect 6s device landscape mode in scene[just click landscape orientation] : go to vary for traits select both width and height. Start your work now. Remove the constraint of width. Add new constraint of width give the constraint 0.4 screen width.
2.- Select 6s Plus device landscape mode in scene[just click landscape orientation] : go to vary for traits select both width and height. Start your work now. Remove the constraint of width. Add new constraint of width give the constraint 0.4 screen width. Now its works perfect in i phone not in i pad because i pad size is different. We need to some work in i pad then it works i pad also. Try it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With