更新时间:2023-02-03 09:17:16
这是一种实现方法:
现在,当您处于纵向时,通过使红色框的宽度像以前一样为90%,自动版式"将能够满足您的所有限制.切换到横向时,等高"约束将确保红色框不会超过高度的90%,因为该约束的优先级为1000,但是自动布局"还会使框尽可能大,以尝试最适合等宽"约束.
Now, when you are in portrait, Auto Layout will be able to satisfy all of your constraints by making the width of the red box to be 90% as before. When you switch to landscape, the Equal Heights constraint will ensure that the red box doesn't grow beyond 90% of the height since this constraint has a 1000 priority, but Auto Layout will also make the box as big as possible in an attempt to best serve the Equal Widths constraint.