gpt4 book ai didi

ios - UIImageView 图像自动缩放

转载 作者:行者123 更新时间:2023-11-28 19:16:03 25 4
gpt4 key购买 nike

我有自定义的 UITableViewCell 和 4 个 UIImageViews。我在 UIImageView.image 中设置了不同大小的图像,但我想按比例缩放它(顶部/底部和左侧/右侧没有黑线。我该怎么做?

最佳答案

您可以使用 contentMode 属性来缩放图像。

如果你想让你的图像在 imageview 框架中适合它的纵横比,设置

imageView.contentMode = UIViewContentModeScaleAspectFit。也可以尝试使用 AspectFill。

设置imageView的backgroundColor为clearColor;

关于ios - UIImageView 图像自动缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12005846/

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