-1

I have added an Imageview to my View.(Simulated Metrices Size:Iphone 3.5 inch).

Constarints Added to the ImageView as follows:

Horizontal Space -(-3) Horizontal Space Vertical Space - (141) Vertical Space - (67)

Imageview Frame = (0,67,323,272)

This image looks fine in Iphone 4s Simulator.

But the image gets elongated in Iphone 5s and 6 and 6Plus simulators.

Again if i am doing the whole thing in a view of Size iphone 4.7 inch The image gets shortened in a iphone 4s simulator.

How to solve this issue ??

  • 3
    You need to add some images that include `1)` the problem `2)` the correct outcome and `3)` the constraints in operation. As an aside, rather than thinking about "devices" you need to think about `Size Classes` instead. – Robotic Cat Jun 24 '15 at 17:47

2 Answers2

1

The Frame of your UIImageView will adjust itself according to your layout constraints. the constraints are depending in the size of the screen, so the imageview will change its size depending on the device that the app runs on. to solve this, you can either set the contentMode of the imageview to UIViewContentModeScaleAspectFit,

myImageview.contentMode = UIViewContentModeScaleAspectFit;

or you can change the constraints to have a fixed height instead of a variable one. but changing the content mode is probably easier ;)

katzenhut
  • 1,742
  • 18
  • 26
0

It not clear what you are seeking to do. If you constraint the images view's width and height and just set it's horizontal and vertical space the image won't elongate. But, if you want to have the image view in different sizes depending on the device then play with the image setting in the image view's storyboard settings at the right.

Dante Puglisi
  • 648
  • 7
  • 24