所有iPad的定期/正常位置调整约束,包括iPad pro? [英] Regular / Regular position sizing constraints for all iPads, including iPad pro?

查看:175
本文介绍了所有iPad的定期/正常位置调整约束,包括iPad pro?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在约束中使用了乘数,来调整我的视图大小。但是在我的约束位置,我使用的价值,我改变不同的大小类。

I've used multipliers in my constraints, to size my views. However in my constraints for position I've used values, which I change for different sizing classes.

但是使用常规/常规的大小类别为iPad Pro它的位置值是'

However using regular / regular sizing classes for iPad Pro it's positions values aren't big enough, but for other iPads it's fine.

我真的不需要添加定位视图乘法器为我的所有视图提供百分比空间,以及我?

I seriously don't have to add positioning views with multipliers to provide percentage spaces for all my views as well do I?

推荐答案

我们要做的是设置屏幕顶部和子视图顶部之间的边距到屏幕的大小。这意味着约束必须与超级视图的高度相关。

What we're after is to set the margin between the top of the screen and the top of the subview with relation to the size of the screen. This means the constraint must be related to the superview's height.

尝试设置两个视图之间的距离(在传统意义上)实际上是一个在这种情况下的想法。相反,试试这个。

Trying to set the distance between the two views (In the traditional sense) is actually a bad idea in this case. Instead, try this.

添加一个约束,在超级视图中垂直居中您的视图。现在,在大小检查器(右侧工具栏)中打开约束。

Add a constraint to center your view vertically in the superview. Now, open up the constraint in the size inspector (The right toolbar).

如果您将乘数设置为0.01(0只是将其放回屏幕中央),您的视图将超过屏幕顶部。将中心Y的第一个项目更改为顶部。现在你的看法将在顶部!

If you set the multiplier to 0.01 (0 just puts it back in the center of the screen), your view will go past the top of the screen. Change the first item from Center Y to Top. Now your view will be at the top!

从这里,您可以更改常数向下调整固定金额,然后更改乘数,即可将视图向下进一步按比例移动到屏幕的高度。公式将类似于

From here, you can change the constant to move your view down a fixed amount and change the multiplier to move your view down further proportionally to the screen's height. The formula would look like

subViewYPosition = constant + (superviewHeight * multiplier)

您需要调整常数和乘数以满足您的需求,但我相信这是一个很好的解决方案。
下面是一个例子。

You will need to adjust the constant and multiplier to suit your needs, but I believe this is a good solution to the problem. An example of this is shown below.

这篇关于所有iPad的定期/正常位置调整约束,包括iPad pro?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆