Xcode 6 - create UIImageView with equal heights changing with screen Orientation?

149 views Asked by At

Why doesn't the height of my UIImage change when I run it on a different device? I set the height to 187 too all 4 images and I want display them with equal heights so they fill the full screen?

Here's the constraints for each image: enter image description here

The image on the right is a screen-shot taken from Xcode. The image on the left is a screen-shot on iPhone 6

enter image description here

2

There are 2 answers

6
akashivskyy On BEST ANSWER

UIImage's size doesn't change because it's the same JPG/PNG file, regardless of the device. What you need is a set of proper layout constraints.

I suggest the following approach:

  1. Connect first image view's top to superview's top,
  2. Connect last image view's bottom to superview's bottom,
  3. Set equal heights for all image views.

Oh, and don't forget to set some constraints for horizontal axis.

0
Nischal Hada On

Add the constraints as the image below

Select all of the image first and give constraint as below

Step 1

enter image description here

Step 2

enter image description here

Step 3: You will achieve what you wants

enter image description here