gpt4 book ai didi

objective-c - 跳跃动画 : First animation duration doesn't work. IOS

转载 作者:行者123 更新时间:2023-12-01 17:43:53 25 4
gpt4 key购买 nike

我有一个动画,当按下按钮时,它应该跳起来,然后再向下 float 。我使用动画一个让它浮起来,第二个让它下来。无论我做什么,第一个动画都不会 float ,它只是传送到顶部,而第二个动画正是它应该做的。

这就是我所拥有的:

//This animation does not respond to its duration.
[UIView animateWithDuration:.5 delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
CGRect f = imageView.frame;
f.origin.y -= 40;
imView.frame = f;
}
completion:nil];

[UIView animateWithDuration:.7 delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
CGRect f = imageView.frame;
f.origin.y += 40;
imView.frame = f;
}
completion:nil];

另一个问题是我想在整个动画中更改图像,但它总是以我最后声明的图像开始。谢谢!

最佳答案

您的第二个动画会覆盖第一个动画,因为它没有延迟。尝试从第一个动画的完成 block 开始第二个动画。

[UIView animateWithDuration:.5 delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
CGRect f = imageView.frame;
f.origin.y -= 40;
imView.frame = f;
}
completion:^{
[UIView animateWithDuration:.7 delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
CGRect f = imageView.frame;
f.origin.y += 40;
imView.frame = f;
}
completion:nil];
}];

关于objective-c - 跳跃动画 : First animation duration doesn't work. IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11812770/

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