I did a percentage based width for root Stack View.
First I made root stack view equal width to super view and multiplier to 0.7 to get the 70 % of subview. And then horizontally center in a container.It works for all iPhones but it is bigger for iPads. I want make multiplier from 0.7 to 0.5 or 0.6 so that root view may seen perfectly for iPads.
I did not find a + (plus) sign next to multiplier to make it (regular-regular for iPads).
All I want is to make root stack view get 60 percent width of superview for all iPhones and 70 percent width of superview for all iPads .
Is there way to change multiplier value 0.7 for iPhones and 0.6 for iPads?
Of course it is! It could easily be achieved with Size classes, but unfortunately you have to add another constraint for different size class rather than different multiplier for the same constraint.
1) Assuming you have view like that:
2) All you have to do is to add another subview-superview equal-width constraint:
3) Getting conflicting constraints, of course:
4) Set required multiplier for iPad (0.6) on new constraint
5)The tricky part: enable old contraint for all Size classes except Regual Width
, Regular Height
(an iPad size class) and vise-versa for new constraint:
5.1) add wR hR "variation" for the first constraint:
Do the same for the second constraint, but disable it for "install" variation.
At the end both constants should look like:
As you can see, if we preview iPhone, we see only the first constraint activated, in iPad preview only the second constraint activated.