ios UIViewContentModeScaleAspectFit 和 UIViewContentModeScaleToFill 的区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4895272/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 18:47:39  来源:igfitidea点击:

Difference between UIViewContentModeScaleAspectFit and UIViewContentModeScaleToFill?

iosuiimageviewcontentmodeuiviewcontentmode

提问by Madhumitha

what is the difference between UIViewContentModeScaleAspectFitand UIViewContentModeScaleToFill...?

UIViewContentModeScaleAspectFitUIViewContentModeScaleToFill...之间有什么区别?

回答by erkanyildiz

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.

重绘模式用作缩放填充模式。但是当视图几何变化时,它们的绘制方式有所不同。缩放填充模式使用已经渲染的内容,而重绘模式再次渲染内容。

回答by EmptyStack

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

如果您正在谈论UIViewContentMode,以下内容来自Doc

UIViewContentModeScaleToFill

UIViewContentModeScaleToFill

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

如有必要,通过更改内容的纵横比来缩放内容以适应自身的大小。

UIViewContentModeScaleAspectFit

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

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.

缩放内容以填充视图的大小。内容的某些部分可能会被裁剪以填充视图的边界。