IOS图片的填充模式

UIImageView 是工作中最基本的控件了,但往往在给UIImageview 设置图片的时候往往会设置一个重要的属性--->UIContentViewMode ,这虽然是个很简单的属性,但是如果设置不好的话图片填充的时候很容易出现奇怪的效果

UIContentViewModel一共有这些枚举

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,

看起来很简单,但是每次用的时候往往要想一下他们每个的区别,后来发现了这张图,一图顶千言


image

以后每次用的时候看下这张图就OK了!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容