image的contentMode简单理解

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的尺寸要求,将不再缩将放)
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容