如何管理汽车布局两种观点之间的差距 [英] How to manage the gap between two views in auto layout

查看:103
本文介绍了如何管理汽车布局两种观点之间的差距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的自动布局我的的ViewController 我知道如何定义使用约束编程两种观点之间的差距。我想现在要做的是当屏幕尺寸的增加,增加的差距也。因为我的 UIViews 正确定位于iPhone 4S的和5S,但在6,6再加上他们被定位在屏幕的一个小区域。我知道加入乘数我们可以设置一个视图的纵横比,但是,如何增加2次之间的差距时,屏幕HIGHT增加。

更新

让说这形象,,还有这个请登录上面的标签标识。

这是我的verticle位置约束

<$p$p><$c$c>V:|-70-[Title]-130-[lblFirst]-0-[lblSecond]-20-[textusername]-10-[txtpassword]-10-[btnLogin]

这标题是上面这个请登录标签图像130pix。我想提高这个130,当涉及到iPhone 6,6加上


解决方案

以一个UIView与Alpha 0和鲜明的色彩,并用它来代替的差距,使用纵横比用于差距,顶部和底部或左视图,右无论你的情况给谁之间你想差距动态的看法。 ,你也需要一些更多的对齐约束添加到gapView,但它会奏效。我无法找到任何其他方法,所以我必须在所有项目和所有工作正常用这种方法处处要做到这一点很容易。我认为UIView的清晰颜色和alpha 0不会影响屏幕和性能以任何方式。我们可以利用这一点。

下面是一样,如果你有垂直两个文本字段的例子,你想增加他们之间的差距动态再取则之间的观点与文本域完全相同的宽度,并添加这些约束。

1)顶部GapView到上面的文本字段。

2)GapView的底部下方的文本字段。

3)的宽度相等的任何文本字段或开头和结尾的SuperView向或主视图。

4)比例高到主视图(您可以通过从子视图中添加相同的高度,以任何的SuperView通过改变乘数)添加此约束,然后;

和您的GapView会增加,相应减少。

I am using auto layout for my ViewController I know how to define the gap between two views using constraints programmatically. What I want to do now is when the screen size increase, increase the gap also. Because my UIViewsare positioned properly in iphone 4s and 5s but in 6 and 6 plus they are positioned in a small area of the screen. I know adding multiplier we can set the aspect ratio of a view but, how to increase the gap between 2 views when the screen hight increase.

UPDATE

Let say this image,, there is a logo above this please login label.

This is my verticle position constraint

V:|-70-[Title]-130-[lblFirst]-0-[lblSecond]-20-[textusername]-10-[txtpassword]-10-[btnLogin]

this Title is an image 130pix above to this Please Login label. I want to increase this 130 when it comes to iphone 6 and 6 plus

解决方案

Take a UIView with alpha 0 and clear color and use it instead of the gap and use aspect ratio to the view used for gap and top and bottom or left and right whatever your situation to the views between whom you want to make the gap dynamic. And also you need to add some more alignment constraints to the gapView but it will work. I could not found any other method to do this easily so i have used this method everywhere in all projects and all working fine. I think UIView with clear color and alpha 0 will not effect the screen or performance in any way. We can use this.

Here is an example like if you have two text fields vertically and you want to increase the gap between them dynamically then take a view between then with the exact same width of text field and add those constraints.

1) Top of GapView to upper text field.

2) Bottom of GapView to below text field.

3) Equal width to any text field or leading and trailing to superview or main view.

4) Proportional Height to main view(you can add this constraint by adding equal height from subview to any of superview and then by changing the multiplier);

And your GapView will increase and decrease accordingly.

这篇关于如何管理汽车布局两种观点之间的差距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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