I’ve an UIImageView with content mode Aspect Fit of size 220×155. I’m dynamically inserting different images in different resolutions, but all larger than the size of the UIImageView. As the content mode is set to Aspect Fit, the image is scaled with respect to the ratio to fit the UIImageView.
My problem is, that if for instance the image inside the UIImageView is scaled to 220×100, I would like the UIImageView to shrink from a height of 155 to 100 too to avoid space between my elements.
How can I do this?
If I got you right, it would be something like this: get image size by:
calculate scale ratio on width
check scaled height (using same ratio to keep aspect)