简体   繁体   中英

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 ?

What I want the cell to look like Eventbright event 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. 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% )

From control and drag select equal width. as shown

在此输入图像描述

在此输入图像描述

  • stack view 2 is fill equally
  • stack view 3 is fill equally

Hope it can help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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