您当前的位置: 首页 >  ui

培根芝士

暂无认证

  • 1浏览

    0关注

    446博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

iOS设置UIView的contentMode

培根芝士 发布时间:2019-09-02 16:07:25 ,浏览量:1

contentMode是UIView的属性,可以设置内容展示模式。

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,
};

UIViewContentModeScaleToFill,表示通过缩放来填满view,也就是说图片会变形。 UIViewContentModeScaleAspectFit,表示按比例缩放并且图片要完全显示出来,意味着view可能会留有空白 UIViewContentModeScaleAspectFill,表示按比例缩放并且填满view,意味着图片可能超出view,可能被裁减掉,实际应用中通过view.clipToBounds = YES把超出部分裁减掉。

UIViewContentModeCenter,表示图片居中显示,尺寸按照图片实际尺寸,意味着图片可能会留白,也可能会超出view。

 

关注
打赏
1660824269
查看更多评论
立即登录/注册

微信扫码登录

0.0537s