简体   繁体   English

Swift 元素在堆栈视图中的高度

[英]Swift elements's height in stackview

I have a stackView like this.我有一个这样的stackView。 在此处输入图像描述

If Data has not images image will be hidden.如果数据没有图像图像将被隐藏。 Then label's text is "", but label's height is to be long.那么标签的文字是“”,但标签的高度要长。 I want label does not fill stackview.我想要 label 不填充堆栈视图。 How can I do?我能怎么做?

A tableview or a collectionview might be more appropriate for UI containers. tableview 或 collectionview 可能更适合 UI 容器。 They are more suitable for a dynamic feature like you mentioned.它们更适合您提到的动态功能。 Having said that you can play with the configuration of the stack view distribution, spacing, and alignment to dynamically set the StackView to accommodate the sizes you wish.话虽如此,您可以使用堆栈视图分布、间距和 alignment 的配置来动态设置堆栈视图以适应您希望的大小。 In addition to set sizes of subview using - intrinsiccontentsize除了使用 -intrinsiccontentsize 设置子视图的大小

Here are two links that can help you with that: UIStackView 1 UIStackView 2 Intrinsiccontentsize这里有两个链接可以帮助你: UIStackView 1 UIStackView 2 Intrinsiccontentsize

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

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