Arun kumar Arun kumar - 4 months ago 32x
Swift Question

set image height in aspect fill in auto layout in Xcode

how to set the images in aspect fill when using the auto layout. When i design in storyboard it's perfectly fine but when setting the image, the height of image view goes very high. i want it to be a constant , i've also added the constant for that but it doesn't work. i'm using the latest Xcode.


From Apple Document, AspectFill is not guaranteed to clip the content.

The option to scale the content to fill the size of the view. Some portion of the content may be clipped to fill the view’s bounds.

enter image description here

So you need to set clipToBounds property to True, or set it in Storyboard.

enter image description here