[英]set superview height constraint according to subview height constraint
1) View A , view B , View C height & width are equal 1)视图A,视图B,视图C的高度和宽度相等
2) View A height depends on Label1 & Label2 height 2)视图高度取决于Label1和Label2高度
3) View B height depends on Label3 3)视图B高度取决于Label3
4) View c height depends on Label4 4)视图c高度取决于Label4
5) I want to take max height from View A, View B & View C but all are equal 5)我想从视图A,视图B和视图C中获取最大高度,但都是相同的
6) View X heights depend on max of (View A,View B & View C) 6)视图X高度取决于最大值(视图A,视图B和视图C)
How to achieve this through auto-layout? 如何通过自动布局实现这一目标?
Thanks in advance 提前致谢
It can be done easily in the Xib or storyboard. 它可以在Xib或故事板中轻松完成。 Refer to the Screen shot of the constraints created.
请参阅创建的约束的屏幕截图。
V1 --> First View V1 - >第一视图
V2 --> Second View V2 - >第二视图
V3 --> Third View V3 - >第三视图
V1L1 --> First View's First Label V1L1 - > First View的第一个标签
V1L2 --> First View's Second Label V1L2 - > First View的第二个标签
V2L1 --> Second View's First Label V2L1 - >第二视图的第一个标签
V3L1 --> Third View's First Label V3L1 - >第三视图的第一个标签
The first View is Having the width constraint of 180 and all the views(V1, V2, V3) are having equal width and equal height constraints. 第一个视图的宽度约束为180,所有视图(V1,V2,V3)具有相等的宽度和相等的高度约束。
All the Labels Lines count is set to zero in the attribute inspector, This enables the label height increase as text of the label is more. 在属性检查器中,所有标签行数都设置为零 。这样可以使标签高度增加,因为标签的文本更多。
The height of V1, V2 and V3 is determined by the content of the labels. V1,V2和V3的高度由标签的内容决定。
Views height increases based on the labels content and all the view are given equal heights , Hence the Content view height will be the height of the max(V1.height, V2.height, V3.height)
. 视图高度根据标签内容增加,并且所有视图都具有相等的高度,因此内容视图高度将是
max(V1.height, V2.height, V3.height)
高度max(V1.height, V2.height, V3.height)
。 Also V1.height = V2.height = V3.height = max(V1.height, V2.height, V3.height)
另外
V1.height = V2.height = V3.height = max(V1.height, V2.height, V3.height)
Below is at the clear image of constraints. 下面是约束的清晰图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.