iOS UIImageView的 contentMode属性

//用于设置图片显示模式

@property(nonatomic)                UIViewContentMode contentMode;                // default is UIViewContentModeScaleToFill;

//最常用的3个枚举值

1、按照"UIImageView"的宽高比缩放图片至图片填充整个UIImageView;

UIViewContentModeScaleToFill

2、按照"图片的宽高"比例缩放图片至图片的宽度或者高度和UIImageView一样, 并且让整个图片都在UIImageView中. 然后居中显示,此种情况可能不会完全填充UIImageView,多余地方留白

UIViewContentModeScaleAspectFit,      // contents scaled to fit with fixed aspect. remainder is transparent  

3、按照"图片的宽高"比例缩放图片至图片的宽度和高度填充整个UIImageView. 然后居中显示,图片可能会被裁剪掉一部分

UIViewContentModeScaleAspectFill,    // contents scaled to fill with fixed aspect. some portion of content may be clipped.

你可能感兴趣的:(iOS UIImageView的 contentMode属性)