AVMakeRectWithAspectRatioInsideRect 的使用

AVMakeRectWithAspectRatioInsideRect

根据苹果文档说明:

Use this function when attempting to fit the presentation size of a player item object’s content within the bounds of another CALayer. Use the returned CGRect as the player layer’s frame property value

此外, 如果要在使用aspectFillMode模式的UIImageView中显示UIImage的精确大小的话(让图片适应一个矩形,不改变原始长宽比), 使用这个函数也是很有用的。它可以根据你提供的size,然后自动计算当前size按比例能缩放成多大的,然后返回.返回的Rect是一个居中显示的矩形

在这里插入图片描述

注意,此函数返回的CGRect的中心与函数中传递的boundingRect的中心相同

函数的声明:

CGRect AVMakeRectWithAspec

猜你喜欢

转载自blog.csdn.net/zhanglei5415/article/details/126409815