UIViewContentMode

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:啥意思我还不懂。

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

  • UIViewContentModeCenter:这个 image 的中心与 frame 的中心重合。
  • UIViewContentModeTop:这个 image 的上边缘与 frame 的上边缘重合。
  • UIViewContentModeBottom:这个 image 的下边缘与 frame 的下边缘重合。
  • UIViewContentModeLeft:这个 image 的左边缘与 frame 的左边缘重合。
  • UIViewContentModeRight:这个 image 的右边缘与 frame 的右边缘重合。
  • UIViewContentModeTopLeft:类似。
  • UIViewContentModeTopRight:类似。
  • UIViewContentModeBottomLeft:类似。
  • UIViewContentModeBottomRight:类似。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值