Xcode 8 device oriented constraints within the same size class

69 Views Asked by At

I'm having trouble with the size of a UIImageView within the same Size Class (Trait Collection now).

Here's my concrete problem, I have a UIImageView which goes smaller as the device goes smaller, however it's the same Size Class, so I can't add specific Size Class constraints to prevent this.

  • iPhone 7 plus :

iPhone 7 plus

  • iPhone 4 :

iPhone 4

2

There are 2 best solutions below

0
On

All you can do is remove leading, trailing and bottom constraints and follow the below steps...

1) Fix height and width of UIImageView.
2) And set this UIImageView to Horizontal center of superview.

Now it'll work in all devices without downsize of UIImageview.

0
On

Check this, For iPhone 7 plus you need 3x images and iPhone 4 you need 2x images,imageView has intrinsic content size. So only concern is to position in a right place than giving height or width constraints/by pinning it on four sides. So just center it horizontally to its superview and give vertical spacing to the below view (label or button as I can see there).