In Interface Builder, use the following configuration:
There are two important settings, namely:
Mode: Aspect Fill
Clip Subviews
It can also be done programmatically:
[imageView setContentMode:UIViewContentModeScaleAspectFill];
[imageView setClipsToBounds:YES];
This will correctly fill the view with the image, keep its aspect ratio and hide what doesn't fit.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…