标签:
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,
UIViewContentModeScaleToFill:将图片任意伸缩至填充整个UIImageView(忽略原有的宽高比,只负责填充满,此模式下图片基本上都会变形)
UIViewContentModeScaleAspectFit: 将图片等比例伸缩,直到能把整张图片装进ImageView(图片不会变形,但ImageView中图片四周可能有空白)
UIViewContentModeScaleAspectFill: 将图片等比例伸缩,直到宽度等于UIImageView的宽度or图片的高度等于UIImageView的高度为止,然后将图片居中显示
UIViewContentModeRedraw : 调用了setNeedsDisplay方法时,就会将图片重新渲染.
UIViewContentModeCenter:居中显示
......简单的看英文就能懂的就不一一介绍了!
我们还可以设置超出边框的内容都剪掉:
topView.clipsToBounds = YES;
举例:新浪微博里面的图片,就是采用了UIViewContentModeScaleAspectFill这种模式来展示图片的。
[BS-24] UIImageView的contentMode属性
标签:
原文地址:http://www.cnblogs.com/stevenwuzheng/p/5517288.html