自动版式大小类 - 不同比例的高度 [英] AutoLayout Size Classes - different proportional heights
问题描述
我需要设置一个子视图的高度正比于它的父。在iPad上,我需要它的高度的三分之一,而在iPhone上我需要它的一半。在AnyAny规模一流,我创建了约束和倍频设置为0.3333333。这做什么它应该在iPad上。当我改变大小类CompactRegular,我改变约束的乘数为0.5。尽管这使得它的一半在iPhone,它也做它的iPad。我如何让它这样大小的类将有不同的乘数?
I need to set the height of a subview to be proportional to its parent. On iPads, I need it to be one third of the height while on iPhones I need it to be one half. In the "AnyAny" size class, I create the constraint and set the multiplier to 0.3333333. This does what it should on iPads. When I change the size class to "CompactRegular", I change the multiplier of the constraint to 0.5. Although this makes it half on iPhones, it also does it for iPads. How do I make it such that the size classes would have different multipliers?
推荐答案
您将需要添加一个新的约束紧凑型/定期,并确保原来只安装在任何/任何像这样:
You'll need to add a new constraint for Compact/Regular, and make sure the original one is only installed in Any/Any like so:
- 在任何/所有,加上原有的约束(subview.height = superview.height * 0.33)。
- 转为手机/常规,并选择previously又一制约因素。
- 在尺寸检查,旁边的设置,点击+按钮,然后选择紧凑型/常规。现在,您可以禁用契约安装/定期(见图片)。
- 添加新的约束(subview.height = superview.height * 0.5),并确保它仅安装在紧凑型/常规模式。
这篇关于自动版式大小类 - 不同比例的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!