简体   繁体   English

如何在 UIStackView 中动态设置元素之间的间距?

[英]How to set dynamically spacing between elements in UIStackView?

How to with constrains set dynamically spacing between elements in UIStackView?如何使用约束在 UIStackView 中的元素之间动态设置间距?

If I'll try to set spacing in Attribute inspector with IPhone 7 device, I'll get something like this:如果我尝试使用 iPhone 7 设备在属性检查器中设置间距,我会得到如下结果:

代码

But when I'll want to simulate it with IPhone 5 device, I'll get this:但是当我想用 iPhone 5 设备模拟它时,我会得到这个:

Iphone 5

My text will cropped.我的文字将被裁剪。 So how to get result with non-cropping text inside all elements?那么如何在所有元素中获得非裁剪文本的结果呢? Thanks!谢谢!

I've got it!我懂了! Simply needed to add constraint to stackview of full page and set distribution to Fill and it's all!只需将约束添加到整页的堆栈视图并将分布设置为填充即可! I spent couple days for that...我花了几天时间...

就我而言,将堆栈视图分布设置为 .equalSpacing 有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM