在日常开发中经常会遇到图片的展示,那么图片的展示效果是大家非常关心的问题。
typedef NS_ENUM(NSInteger, UIViewContentMode) {
UIViewContentModeScaleToFill,
UIViewContentModeScaleAspectFit, // contents scaled to fit with fixed aspect. remainder is transparent
UIViewContentModeScaleAspectFill, // contents scaled to fill with fixed aspect. some portion of content may be clipped.
UIViewContentModeRedraw, // redraw on bounds change (calls -setNeedsDisplay)
UIViewContentModeCenter, // contents remain same size. positioned adjusted.
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
};
图片是来自网络。
当然大家可以根据需要进行调整,比如自己在做相册的展示是便用到了并作了相应的处理,效果非常nice;
cell.iconImageView.contentMode = UIViewContentModeScaleAspectFill;
cell.iconImageView.clipsToBounds = YES;//子视图超出父视图部分裁剪