image的contentMode
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,
大致分为三种
- UIViewContentModeRedraw 重新绘制
- 带有scale代表有可能被拉伸或者压缩
- 带有Aspect说明缩放带有比例UIViewContentModeScaleAspectFit、UIViewContentModeScaleAspectFill
- 缩放不带比例UIViewContentModeScaleToFill
- 不带有scale只是在不同位置的展示
- UIViewContentModeCenter
- UIViewContentModeTop
- UIViewContentModeBottom
- UIViewContentModeLeft
- UIViewContentModeRight
- UIViewContentModeTopLeft
- UIViewContentModeTopRight
- UIViewContentModeBottomLeft
- UIViewContentModeBottomRight
UIViewContentModeScaleAspectFit与UIViewContentModeScaleAspectFill的区别
- UIViewContentModeScaleAspectFit宽高比不变 自适应(宽和高都满足ImageView的尺寸,将不再缩将放)
- UIViewContentModeScaleAspectFill宽高比不变 填充(宽高有一个达到imageView的尺寸要求,将不再缩将放)
网友评论