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

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

问题描述

我使用自动布局为我的 ViewController 我知道如何使用约束编程方式定义两个视图之间的差距。我现在想做的是当屏幕尺寸增加时,增加间隙。因为我的 UIViews 在iPhone 4s和5s中正确定位,但在6和6加上,它们位于屏幕的一个小区域。我知道添加乘数我们可以设置视图的宽高比,但是当屏幕高度增加时,如何增加2个视图之间的差距。

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

UPDATE

>

让我们说这个图片,上面有一个标志,请登录标签。

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

这是我的垂直位置约束

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

这个标题是一个图像130pix以上这个请登录标签。我想在iphone 6和6 plus时增加这个130

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

推荐答案

使用alpha 0和清晰的颜色和UIView使用它,而不是间隙,并使用宽高比的视图用于差距和顶部和底部或左和右任何你的情况,你想要使之间的动态间隙的视图。还需要添加一些更多的对齐约束到gapView,但它会工作。我找不到任何其他方法来做这很容易所以我已经使用这个方法无处不在所有的项目和所有工作正常。我认为UIView与清晰的颜色和alpha 0将不会以任何方式影响屏幕或性能。我们可以使用这个。

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)GapView顶部到上部文本字段。

1) Top of GapView to upper text field.

2)GapView底部到文本字段下面。

2) Bottom of GapView to below text field.

3)等于任何文本字段的宽度或前导和尾随超视图或主视图。

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

4)与主视图的比例高度(您可以通过从子视图到任意超级视图添加等高,然后通过更改乘数来添加此约束);

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);

您的GapView将相应地增加和减少。

And your GapView will increase and decrease accordingly.

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

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