UIImageView 的 UIViewContentMode

2017-03-29  本文已影响40人  sunflower1518

UIViewContentMode

typedef enum {
    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,
} UIViewContentMode;

UIViewContentModeScaleToFill


UIViewContentModeScaleToFill 充满frame会变形

UIViewContentModeScaleAspectFit 长边为主 短边留缝隙


UIViewContentModeScaleAspectFit 长边为主 短边留缝隙

UIViewContentModeScaleAspectFill 短边为主 长边截取


UIViewContentModeScaleAspectFill 短边为主 长边截取

UIViewContentModeCenter 标尺图片原始尺寸 frame太小会超出


UIViewContentModeCenter 标尺图片原始尺寸 frame太小会超出

UIViewContentModeTop 标尺图片原始尺寸 frame太小会超出


UIViewContentModeTop 标尺图片原始尺寸 frame太小会超出
上一篇 下一篇

猜你喜欢

热点阅读