您的位置:首页 > 产品设计 > UI/UE

UI基础_UIImageView的contentMode总结

2016-07-13 21:25 253 查看
使用到的UIViewContentMode
typedef NS_ENUM(NSInteger, UIViewContentMode) {
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,
};


ScaleToFill:为将图片按照整个区域进行拉伸(会破坏图片的比例)

ScaleAspectFit:将图片等比例拉伸,可能不会填充满整个区域

ScaleAspectFill:将图片等比例拉伸,会填充整个区域,但是会有一部分过大而超出整个区域。

Top,Left,Right等就是将图片在view中的位置进行调整。

注:使用ScaleAspectFill后需要设置clip,

xib中需要在clip subview上打钩

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  contenMode