Search code examples
iosautolayoutsize-classeslaunch-screen

launch screen xib not displaying imageview correctly


I'm using a launch screen xib and I can't get the image within the UIImageView to appear. Currently, I have a UILabel with the imageView placed right below the label and also centered horizontally. I set all the constraints for the imageView but for some reason the label appears but the image doesn't. This is my first time using the whole wAny hAny size classes. Is there something I'm missing?

enter image description here

enter image description here


Solution

  • This is happening because of the horizontal space constraints of the imageView, both the leading and trailing space to the superview. Here the launch screen is laid out in the wAny|hAny size class. It could not satisfy the Horizontal space -(196) on a smaller device. So what you can do

    1. Remove the horizontal space constrains(both leading&trailing) of imageView
    2. Add widthconstraint to the imageView or Aspect Ratio could be more appropriate
    3. Other constraints looks fine, top & bottom spacing and centre horizontally in container keep as it is