Search code examples
iosxcode6interface-builderconstraintsxcode-storyboard

How to properly constrain images in interface builder


I'm new to iOS development and am struggling with interface builder to layout a view that has 3 images. I want three images going across the view. So the images will need to be scaled a little differently for different devices. I am hoping to do this with constraints. I am fairly close. Here is a screenshot:

enter image description here

The images are actually resizing and becoming bigger on the larger device screens which is what I want and the spacing is working to stop them from overlapping each other on small devices. I just need to stop the two side images from being stretched tall. I don't want to specify a height constraint because they do need to resize for specific devices sizes. Any help to add a constraint that will make the outer images not stretch tall is much appreciated.


Solution

  • Set the UIImageView 's content mode to be aspect fit. It will be always stretched in it's correct aspect ratio Screen

    Instead of Scale to Fill select Aspect Fit