I put an image view in a static table view cell. The image is now being stretched to fit the whole view. I want the image to:
- be centered in the image view
- be in the largest size possible but
- not exceed the bounds of the image view and
- keeps the aspect ratio of the image
First I went to the docs of
UIImageView. But didn't find anything useful. Then I looked at the docs of
UIImage and found
UIImageResizingMode. But that enum only contains
Tile, which is not what I wanted. I then found this post which told me to
logo.contentMode = .Center
But the image is still stretched. I then tried this
logo.contentMode = .ScaleAspectFill
But the result is the same.
Please tell me a good way to do this!
The image view has the following constraints: