Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 884
Arun kumar Avatar asked Dec 19 '22 16:12

Arun kumar


1 Answers

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

like image 152
ilovecomputer Avatar answered Dec 25 '22 22:12

ilovecomputer