UIImageView的ContentMode的這些參數(shù)阳欲,這些參數(shù)一般就能滿分我們的開發(fā)需求
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:圖片拉伸至填充這個(gè)UIImageView(圖片可能變形)
轉(zhuǎn)載自 http://www.myexception.cn/mobile/2052661.html
UIViewContentModeScaleAspectFit : 圖片拉伸至完全顯示在UIImageView里面為止(圖片不會(huì)變形)
UIViewContentModeScaleAspectFill : 圖片拉伸至 圖片的寬度等于UIImageView的寬度 或者 圖片的高度等于UIImageView的高度為止,然后將圖片居中顯示
UIViewContentModeRedraw : 調(diào)用了setNeedsDisplay方法時(shí)卿拴,就會(huì)將圖片重新渲染
UIViewContentModeCenter:居中顯示
蝇庭。。郎嫁。秉继。別的跟這個(gè)也是一樣的了舱痘,用的少
我們還可以設(shè)置超出邊框的內(nèi)容都剪掉:
topView.clipsToBounds = YES;
總結(jié)一下:
凡是帶有Scale單詞的成艘,圖片都會(huì)拉伸
凡是帶有Aspect單詞的睬愤,圖片都會(huì)保持原來的寬高比会宪,圖片不會(huì)變形