1

I'm following tutorial in appcoda. The problem is when preview the stackview between different devices the height not following the size of the device.

Here is what i want:

Here is what i want

and here is what i got:

here is what i got

Do constraint effect height in different devices ? or you need code the height for different devices ?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253

1 Answers1

1

Choose the Image in storyboard and try to change "Content Mode" option as shown in this picture below

picture.

I believe "Aspect Fill" will fix it.

Vinodh
  • 5,262
  • 4
  • 38
  • 68
reza karimi
  • 164
  • 1
  • 8
  • now the image become smaller in big screen https://imgur.com/a/K6CL7 do i set the content mode first before embed the stackview ? – Yonathan Hans Sep 04 '17 at 04:04
  • No it doesn't matter when you do it. Whenever you do it, it will take effect. But as I see in the picture you sent in the comment, the picture size is too small. What I suggest is to set the constraints of your image from the right and left edge of the screen, so that in any screen size, your image has a constant space from the right and left edge of the super view of it. (in your case the super view of the image is the hole screen of the device) – reza karimi Sep 04 '17 at 04:16
  • update its seem i make a mistake now the picture its like should be thx @TeddyBear but now the image and text position is ruined https://imgur.com/a/63CzG. How to make the image below the text ? – Yonathan Hans Sep 04 '17 at 04:22
  • You can use vertical stackview. If you put both, the text and the picture, in the stackview, and add a constraint for the picture to set its distance with the object above it (or either adding a constraint for the text to set a distance with the object under it), Xcode will automatically handles the problem, no matter what device it is. – reza karimi Sep 04 '17 at 04:39
  • do i set the constraint for every image to object above it ? – Yonathan Hans Sep 04 '17 at 06:13
  • Depends on the situation but in your case, yes. – reza karimi Sep 05 '17 at 01:22