使用到的UIViewContentMode
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,
};
ScaleToFill:为将图片按照整个区域进行拉伸(会破坏图片的比例)
ScaleAspectFit:将图片等比例拉伸,可能不会填充满整个区域
ScaleAspectFill:将图片等比例拉伸,会填充整个区域,但是会有一部分过大而超出整个区域。
Top,Left,Right等就是将图片在view中的位置进行调整。
注:使用ScaleAspectFill后需要设置clip,
xib中需要在clip subview上打钩