Arun kumar Arun kumar - 1 year ago 206
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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download