Image height limitation does not work

I have a UIImageView and use autostart to add height and width restrictions (and others). There are no conflicting restrictions or warnings. I request an image from the database and set the image of the image for this image. However, the image appears with a much higher height than I indicated through the restrictions. How to fix it?

+4
source share
3 answers

This line should solve your problem:

yourImageView.clipsToBounds = true

You can do this on the Storyboard by checking the "Moving Clips" of your UIImageView.

+2
source

1

   YourImageView.contentMode=UIViewContentModeScaleAspectFit;

, - contentMode, , , .

2. , []

0

If you get the image from the server, you should resize the image to fit your imageView size ... its best practice.

0
source

Source: https://habr.com/ru/post/1617826/


All Articles