UIViewContentMode

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
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容