gpt4 book ai didi

ios - UIViewContentModeScaleAspectFill 不保持图像的纵横比

转载 作者:行者123 更新时间:2023-11-28 17:53:38 28 4
gpt4 key购买 nike

我在 UICollectionViewCell 中使用 UIImageView。我已将 contentMode 设置为 UIViewContentModeScaleAspectFill 并将 Clip subviews 设置为 YES

enter image description here

静止图像的宽高比未保持。它会缩小图像的宽度/高度。

请注意,我知道我可以通过代码居中裁剪图像,但我正在寻找一种无需使用代码来更改图像大小的方法。我也不能使用 UIViewContentModeCenter 因为实际图像比 UIImageView 大得多。

最佳答案

为了保持宽高比,您必须使用 UIViewContentModeScaleAspectFit 而不是 UIViewContentModeScaleAspectFill。

关于ios - UIViewContentModeScaleAspectFill 不保持图像的纵横比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23080019/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com