in iOS Storyboard horizontal StackView center align elements and impose height of first element on all elements

686 views Asked by At

In my storyboard file, I have a horizontal StackView which is center aligned (both horizontally and vertically) in parent view. This stack contains three element

  1. Label "Hi"
  2. Image (an image from resource folder)
  3. Label "World"

StackView configuraation:

Distribution = Fill

Alignment = Last Baseline

In storyboard all items looks of the same height, but when ran on device, two label stays same size but image vertically resizes, and height start to mismatch with two label.

How can I impose height restriction on image, to match with label heights?

Note I have not specified a fixed height for any of my elements.

1

There are 1 answers

1
Kudos On

I want you to make some changes:

  1. Distribution = Fill Equally
  2. Give equal height constraint to image, both labels.
  3. You can set content mode for image to Scale to Fill to make image cover whole area. enter image description here
  4. You are Done.

Result: See below Image enter image description here