gpt4 book ai didi

ios - 无论如何要将 UIImageView 的 contentMode 从 aspectFill 动画化到 aspectFit?

转载 作者:可可西里 更新时间:2023-11-01 05:02:01 26 4
gpt4 key购买 nike

[UIView animateWithDuration:30.0f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{
v.contentMode = UIViewContentModeScaleAspectFit;
v.frame = v.superview.bounds;
} completion:^(BOOL finished) {
[v removeFromSuperview];
}];

我想要一个 UIImageView 调整大小并更改 contentMode,但上面的代码不起作用。它在动画开始时立即更改了 contentMode。

有什么办法让它动起来吗?

最佳答案

正如其他人所提到的,无法为 contentMode 设置动画。

这个库的存在就是为了解决这个问题! https://github.com/patrickbdev/PBImageView

imageView.contentMode = .scaleAspectFit

UIView.animateWithDuration(1) {
self.imageView.contentMode = .scaleAspectFill
}

关于ios - 无论如何要将 UIImageView 的 contentMode 从 aspectFill 动画化到 aspectFit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15777672/

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