如何在 Xcode 中调整 UIStackView 的子视图大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34243128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to resize subviews of UIStackView in Xcode?
提问by Jim Moody
Every time I try to add something to a UIStackView in iOS it autosizes my subviews into something that is too small, so the text is being cut off.
每次我尝试向 iOS 中的 UIStackView 添加内容时,它都会将我的子视图自动调整为太小的内容,因此文本被截断。
How exactly is this StackView supposed to be used? All the guides said it was easy, just drag your subviews inside it, but I must be doing something wrong..
这个 StackView 到底应该如何使用?所有指南都说这很容易,只需将您的子视图拖到其中即可,但我一定是做错了什么..
Before adding to StackView:
添加到 StackView 之前:
After Adding to StackView:
添加到 StackView 后:
采纳答案by Irfan
This is because stackview itself needs constraints. Add constraints to your stackview and then the stackview will take care of subviews.
这是因为 stackview 本身需要约束。向您的堆栈视图添加约束,然后堆栈视图将处理子视图。
In this case stackview is positioned horizontally and vertically center in container.
在这种情况下,stackview 位于容器的水平和垂直中心。
Let me know if there is still any issue.
让我知道是否还有任何问题。