Xcode 6 - create UIImageView with equal heights ch

2019-05-26 16:49发布

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条回答
【Aperson】
2楼-- · 2019-05-26 17:14

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.

查看更多
smile是对你的礼貌
3楼-- · 2019-05-26 17:27

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

查看更多
登录 后发表回答