Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIViewContentModeScaleAspectFill expands UIView's frame

Given that I have a UIImage that has some large frame.

I put this UIImage into a UIImageView *myImageView;

I set the content mode of myImageView to UIViewContentModeScaleAspectFill.

I also set the frame of myImageView to (50,50).

However, my UIImage is significantly bigger than this smaller frame, and for some reason, the image always expands myImageView's frame size.

How do I ensure that myImageView's frame stays constant and doesn't change from image to image?

Thank you!

like image 584
waylonion Avatar asked Oct 25 '13 14:10

waylonion


1 Answers

Is one side of the image matching the desired dimension (50)? If it is, I suspect that your view is still the intended size, but it is not being clipped. Try setting clipsToBounds on your UIImageView to YES.

like image 182
Holly Avatar answered Nov 10 '22 11:11

Holly