gpt4 book ai didi

iphone - 如何使用 UIView animateWithDuration 正确缩放 UIImageView?

转载 作者:行者123 更新时间:2023-12-03 20:45:49 27 4
gpt4 key购买 nike

我正在缩放 UIImageView,然后使用 UIView animateWithDuration 和 UIViewAnimationOptionAutoreverse 选项恢复它。问题是图像动画在动画结束时有点锯齿(抽搐)。这是我的代码:

[UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionAutoreverse 
animations:^{

myImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);}

completion:^(BOOL finished){if (finished){

myImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0);}}];

我知道我错过了一些东西,但不知道从哪里开始:(

更新1:我正在执行嵌套的 6 个动画,其中每个下一个动画都在上一个动画之后执行。为此,我使用 block 动画并在完整的 block 中执行每个下一个动画。

更新2:我尝试过使用 UIViewAnimationOptionRepeat 选项,但每次缩放动画后仍然有一些闪光效果。

最佳答案

如果不使用 UIViewAnimationOptionRepeat 选项,

UIViewAnimationOptionAutoreverse 不会执行任何操作。您编写的动画会将图像缩小到 90%,然后在完成 block 中恢复到 100%。也许您可以在这个动画之后播放另一个在四分之一秒内缩小到 100% 的动画。像这样的事情:

    [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseInOut 
animations:^{
myImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);}
completion:^(BOOL finished){if (finished){

[UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseInOut
animations:^{
myImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0);}
completion:NULL];}}];

关于iphone - 如何使用 UIView animateWithDuration 正确缩放 UIImageView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7081076/

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