[英]How to Set Equal Width or Equal Height in StackView?
I have six labels here, every two labels are stack in a horizontal view, and all horizontal views are stack in a vertical view, as show below我这里有六个标签,每两个标签在水平视图中堆叠,所有水平视图在垂直视图中堆叠,如下图
Here is what I want: I'd like to set Label1
's width 30% of Label2
regardless of each label's content这是我想要的:无论每个标签的内容如何,我都想将
Label1
的宽度设置为Label2
30%
The outer stack view is set as Aligment:Fill, Distribution:Fill Equally外部堆栈视图设置为 Aligment:Fill, Distribution:Fill Equally
All inner stack view are set as Aligment:Fill, Distribution:Fill所有内部堆栈视图都设置为对齐:填充,分布:填充
I have set Label1
's hugging to 250, and Label2
's as default (so does the others).我已将
Label1
的拥抱设置为 250,并将Label2
为默认值(其他人也是如此)。
And I am trying to set the width by Equal Widths in pic 2. But it is unselected我试图在 pic 2 中通过 Equal Widths 设置宽度。但它没有被选中
what should I do about this?我该怎么办? Preferring doing all the work in the storyboard, but working around in code is ok too.
更喜欢在故事板中完成所有工作,但在代码中工作也可以。
Solution: Just need to select both label to add the constraint, as Below Solution image解决方案:只需要选择两个标签来添加约束,如下图解决方案
IMO, Stack View wont allow to give some fix frame size of the views inside it, we can somewhat control it using available properties. IMO,Stack View 不允许为其中的视图提供一些固定的框架大小,我们可以使用可用属性在一定程度上控制它。
Stack Views are meant for similar type content to be confined inside one view.堆栈视图旨在将类似类型的内容限制在一个视图中。
Option:选项:
0.30
.0.30
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.