Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between UIViewContentModeScaleAspectFit and UIViewContentModeScaleToFill?

People also ask

What is the difference between aspect fill and aspect fit when displaying an image?

The Fit setting will resize an image to fit within the bounds of its container with no cropping. The Fill setting will expand an image to fill the whole container, which may result in some cropping depending on the dimensions of your container and the image you send into it.

What is scale aspect fit?

The option to scale the content to fit the size of the view by maintaining the aspect ratio. Any remaining area of the view's bounds is transparent.


You can see the differences between the content modes here:

enter image description here

Redraw mode works as Scale to Fill mode. But there is a difference in how they are drawn when view geometry changes. Scale to Fill mode uses already rendered content while Redraw mode renders the content again.


If you are talking about UIViewContentMode, the following is from the Doc.

UIViewContentModeScaleToFill

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

UIViewContentModeScaleAspectFit

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

UIViewContentModeScaleAspectFill

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


uiimageview-scaling-explained-visually

enter image description here