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

UIImageView的contentMode属性

2015-09-10 18:32 387 查看
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,
};

默认值是 0,也就是:

UIViewContentModeScaleToFill

一个个来理解下吧:

UIViewContentModeScaleToFill:表示完全填充在 frame 里。

UIViewContentModeScaleAspectFit:保持比例,都在 frame 内。

UIViewContentModeScaleAspectFill:保持比例,填满但 frame 外也有。

UIViewContentModeRedraw:每次设置或更改frame的时候自动调用drawRect.

其他的是相似的,好理解:

UIViewContentModeCenter:这个 image 的中心与 frame 的中心重合。

UIViewContentModeTop:这个 image 的上边缘与 frame 的上边缘重合。

UIViewContentModeBottom:这个 image 的下边缘与 frame 的下边缘重合。

UIViewContentModeLeft:这个 image 的左边缘与 frame 的左边缘重合。

UIViewContentModeRight:这个 image 的右边缘与 frame 的右边缘重合。

UIViewContentModeTopLeft:类似。

UIViewContentModeTopRight:类似。

UIViewContentModeBottomLeft:类似。

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