1 @property(nonatomic) UIViewContentMode contentMode; // default is UIViewContentModeScaleToFill 常用在UIImageView中,设置图片的展示样式
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. 按图片原比例展示,多余尺寸会被裁减掉 图片展示时多采用这种方式,一般和下面的 clipsToBounds属性一起使用
UIViewContentModeRedraw, // redraw on bounds change (calls -setNeedsDisplay)
UIViewContentModeCenter, // contents remain same size. positioned adjusted.
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
};
2 @property(nonatomic) BOOL clipsToBounds; // When YES, content and subviews are clipped to the bounds of the view. Default is NO. 这个属性也常用在UIImageView中,裁减图片