美文网首页
UIViewContentMode

UIViewContentMode

作者: 梓华 | 来源:发表于2021-05-18 16:08 被阅读0次

    Scale 图片会缩放。
    Aspect 保持比例

    UIViewContentModeScaleToFill
    缩放 不用保证比例 那就拉伸

    UIViewContentModeScaleAspectFit
    缩放 又保证比例 那么缩小咯 露出黑边

    UIViewContentModeScaleAspectFill
    缩放 又保证比例 那么放大咯 显示不全

    https://www.jianshu.com/p/6f51b22ef678

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

    @property(nonatomic) UIViewContentMode contentMode; // default is UIViewContentModeScaleToFill

    视图的contentMode属性 默认UIViewContentModeScaleToFill

    先上些图


    UIViewContentModeScaleToFill.png UIViewContentModeScaleAspectFit.png UIViewContentModeScaleAspectFill.png UIViewContentModeCenter.png

    相关文章

      网友评论

          本文标题:UIViewContentMode

          本文链接:https://www.haomeiwen.com/subject/gtmerltx.html