Search code examples
iosswiftuikit

UIImageView spills out of collection view cell


I have a uicollectionview cell with an imageView inside of it. In the cell I have two uiviews that are set to be equal heights, constrained to reach the edges of the cell, and stacked on top of each other. In the top uiview I placed a uiimageview and constrained it to it will be 10 pixels from the top, sides, and bottom.

Picture of the xib: enter image description here

The problem that I face is when I place an image in the view and run it this happens:

enter image description here

What I dont understand is why it does that. It doesnt do this when I change the color of the background leading me to suspect that the image is causing it.

Pic of no problem but without image:

enter image description here


Solution

  • By default the estimate size is set to Automatic. Set it to None

    enter image description here