How to manage UIImageView content mode?
Please try this code, Hope it will work for you.
set UIImageView
contentMode
to UIViewContentModeScaleAspectFill
as below :
imageView.contentMode = UIViewContentModeScaleAspectFill;
set autoresizingMask of UIImageView as below :
imageView.autoresizingMask =
( UIViewAutoresizingFlexibleBottomMargin
| UIViewAutoresizingFlexibleHeight
| UIViewAutoresizingFlexibleLeftMargin
| UIViewAutoresizingFlexibleRightMargin
| UIViewAutoresizingFlexibleTopMargin
| UIViewAutoresizingFlexibleWidth );
You just need these two lines:
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.layer.clipsToBounds = YES; // Must do this or else image will overflow