简体   繁体   English

UIStackView:使用故事板更改UIStackView图像宽度

[英]UIStackView : Change UIStackView image width using storyboard

The issue : Image take most of the stack and text shrinks 问题:图像占用大部分堆栈和文本缩小

I tried to change content hugging priority but no changes ! 我试图更改内容拥抱优先级但没有更改!

How to do it in UIStackview using storyboard ? 如何使用故事板在UIStackview中执行此操作?

What I want the cell to look like Eventbright event Cell? 我希望细胞看起来像Eventbright事件Cell? 在此输入图像描述 在此输入图像描述

What I got is an image that take most of the cell? 我得到的是一个占据大部分细胞的图像?

Instead of Fill , change the Distribution of the UIStackView to Fill Proportionally and add constraints for the width of each element. 而不是Fill ,将UIStackViewDistribution更改为Fill Proportionally并为每个元素的宽度添加约束。 Those constraints will serve as a guide to proportions on one element to each other and not as fixed sizes. 这些限制将作为一个元素相互之间比例的指导,而不是固定大小。

I tried it the following way. 我尝试了以下方式。 The overall set up is given in pic: 整体设置以图片形式给出:

在此输入图像描述

At run time result is as given: 在运行时结果如下:

在此输入图像描述

  • First Stack view is fill proportionally 第一个堆栈视图按比例填充
  • imageview width is 1:4 of stackview width (control and drag from imageview to stackview and set equal width to 25% ) imageview宽度是stackview宽度的1:4(控制并从imageview拖动到stackview并将等宽度设置为25%)

From control and drag select equal width. 从控制和拖动选择相等的宽度。 as shown 如图所示

在此输入图像描述

在此输入图像描述

  • stack view 2 is fill equally 堆栈视图2是同等填充
  • stack view 3 is fill equally 堆栈视图3同样填充

Hope it can help 希望它可以提供帮助

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

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