IOS图片的填充模式

作者: luoerliu | 来源:发表于2017-11-13 21:48 被阅读21次
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了!

相关文章

网友评论

    本文标题:IOS图片的填充模式

    本文链接:https://www.haomeiwen.com/subject/vvdtvxtx.html