【iOS】Scale Fill、Aspect Fit 和 Aspect Fill 的区别(Content Mode)

ImageView –  Content Mode中Scale FillAspect Fit Aspect Fill 的区别

Scale Fill:缩放(改变图片比例)以填满整个Image View

Aspect Fit:保持图片原比例,尽可能让图片全部显示出来,Image View 剩下空出来的部分是透明的

Aspect Fill:保持图片原比例,填满整个Image View(图片可能会被裁剪掉)


Scale Fill

 Aspect Fit

Aspect Fill

UIViewContentModeScaleToFillScales the content to fit the size of itself by changing the aspect ratio of the content if necessary.

UIViewContentModeScaleAspectFitScales the content to fit the size of the view by maintaining the aspect ratio. Any remaining area of the view’s bounds is transparent.

UIViewContentModeScaleAspectFillScales the content to fill the size of the view. Some portion of the content may be clipped to fill the view’s bounds.

❤❤点击这里 -> 订阅PAT、蓝桥杯、GPLT天梯赛、LeetCode题解离线版❤❤