AutoLayout class levels - different proportional heights

I need to set the oversight height proportionally to its parent. On iPads I need it to be one third of the height, and on iPhones I need it to be half the height. In the "AnyAny" size class, I create a constraint and set the multiplier to 0.3333333. This does what the iPad needs. When I change the size class to "CompactRegular", I change the constraint multiplier to 0.5. While this does it halfway on the iPhone, it does it for iPads as well. How do I make the size classes have different multipliers?

+3


source to share


1 answer


You will need to add a new limit for Compact / Regular and make sure the original file is set to Any / Any only, e.g .:

  • In Any / Any add the original constraint (subview.height = superview.height * 0.33).
  • Switch to Compact / Regular and select the previously added restriction.
  • In the sizing inspector, next to Set, click the + button and select Compact / Normal. Now you can turn off "installed" in Compact / Regular (see fig.).
  • Add a new constraint (subview.height = superview.height * 0.5) and make sure it is only set in Compact / Regular mode.


Size inspector

+5


source







All Articles