UIViewContentModeScaleToFill
UIViewContentModeScaleAspectFit
UIViewContentModeScaleAspectFill
UIViewContentModeRedraw
UIViewContentModeCenter
UIViewContentModeTop
UIViewContentModeBottom
UIViewContentModeLeft
UIViewContentModeRight
UIViewContentModeTopLeft
UIViewContentModeTopRight
UIViewContentModeBottomLeft
UIViewContentModeBottomRight
注意以上幾個(gè)常量,凡是沒有帶Scale的,當(dāng)圖片尺寸超過 ImageView尺寸時(shí),只有部分顯示在ImageView中。
UIViewContentModeScaleToFill屬性會(huì)導(dǎo)致圖片變形。
UIViewContentModeScaleAspectFit會(huì)保證圖片比例不變,而且全部顯示在ImageView中,這意味著ImageView會(huì)有部分空白。
UIViewContentModeScaleAspectFill也會(huì)證圖片比例不變,但是是填充整個(gè)ImageView的,可能只有部分圖片顯示在frame內(nèi),但是圖片
多出來的部分還是會(huì)顯示frame外。如果不希望超過frame的區(qū)域顯示在屏幕上要設(shè)置clipsToBounds屬性。
imageView.clipsToBounds? = YES;