UIVewContentMode
聲明:感謝 iunion 的圖片
枚舉代碼
typedef enum {
UIViewContentModeScaleToFill,
UIViewContentModeScaleAspectFit,
UIViewContentModeScaleAspectFill,
UIViewContentModeRedraw,
UIViewContentModeCenter,
UIViewContentModeTop,
UIViewContentModeBottom,
UIViewContentModeLeft,
UIViewContentModeRight,
UIViewContentModeTopLeft,
UIViewContentModeTopRight,
UIViewContentModeBottomLeft,
UIViewContentModeBottomRight,
} UIViewContentMode;
Top | Bottom | Left | Right 四種為最基本的布局缔赠,以原大小緊貼四個(gè)方位立哑,不改變大小
TopLeft | TopRight | BottomLeft | BottomRight 四中為四個(gè)角緊貼,不改變大小
ScaleAspectFit -> 不改變比例的情況下高度放到最大敌卓,寬度適應(yīng)(有可能導(dǎo)致寬度超出)
ScaleAspectFill -> 不改變比例的情況下寬度放到最大,高度適應(yīng)(有可能導(dǎo)致高度超出)
ScaleToFill -> 填滿整個(gè)區(qū)域例诀,可能會(huì)導(dǎo)致失真(比例改變)
Center -> 圖片不變菇民,中心居中
Redraw -> 調(diào)用[self setNeedsDisplay]方法,在改變時(shí)調(diào)用邏輯(例如旋屏等)
幾個(gè)不好理解的如下圖所示
※※發(fā)現(xiàn)使用UIImageView時(shí)持钉,fit與fill與普通的UIView相反(待考證)
幾個(gè)例子