3

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? enter image description here enter image description here

What I got is an image that take most of the cell?

Community
  • 1
  • 1
user3662992
  • 688
  • 1
  • 6
  • 16

2 Answers2

7

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.

Odrakir
  • 4,254
  • 1
  • 20
  • 52
2

I tried it the following way. The overall set up is given in pic:

enter image description here

At run time result is as given:

enter image description here

  • 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

enter image description here

enter image description here

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

Hope it can help

Irfan
  • 5,070
  • 1
  • 28
  • 32
  • Where should I type 25% ? – user3662992 Nov 30 '15 at 14:34
  • When you control and drag from imageview to stack view select equal width. then go to size inspector and double click the constraint. you will see the above window show in answer. type 25% in Multiplier. – Irfan Nov 30 '15 at 14:43