0

I am trying to put my image at the center & want to keep the width & height of the image fixed.

I have tried adding constraints : equal width, equal height and have also added a constraint to keep some padding below the label.

When I run it, the size of the image is scaled up and it goes to the top right.

I have tried a lot of permutations & combinations to get it where it in the middle, not of them as worked so far.

sau123
  • 352
  • 5
  • 18

2 Answers2

2

According to your requirement, set the constraints

  • Horizontally in container
  • Vertically in container
  • Width
  • Height

Not equal width, equal height. And I believe going to the top right is because there's no valid horizontal alignment.

zc246
  • 1,514
  • 16
  • 28
0

You can add following constraints to uiimageview :

(I have give fixed height and width of 300, you can have your own variants)

enter image description here

And the output will be...

enter image description here

Hima
  • 1,249
  • 1
  • 14
  • 18