我正在尝试用3个步骤创建动画。第一步应该在缩放的图片上向右移动一点点。第二步是在3秒内放大效果到其他图片。最后一步是再次使用不同的图片在3秒内缩小。我完全按照我的要求完成了前两个步骤,但是当我添加3.步骤时出错了。它就像它试图做2.和3.一起做的步骤。请帮我。这是我的代码。
imgAnimationBase.image = [UIImage imageNamed:@"animation-1.jpg"];
imgAnimationBase.alpha = 1.0;
imgAnimationBase.transform =CGAffineTransformMakeScale(1.5,1.5);
imgAnimationBase.frame=CGRectMake(20, imgAnimationBase.frame.origin.y, imgAnimationBase.frame.size.width, imgAnimationBase.frame.size.height);
[UIView transitionWithView:imgAnimationBase
duration:3.0f
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
imgAnimationBase.frame=CGRectMake(-110, imgAnimationBase.frame.origin.y, imgAnimationBase.frame.size.width, imgAnimationBase.frame.size.height);
}
completion:^(BOOL finished) {
imgAnimationBase.transform =CGAffineTransformMakeScale(1,1);
imgAnimationBase.frame=CGRectMake(10, imgAnimationBase.frame.origin.y, imgAnimationBase.frame.size.width, imgAnimationBase.frame.size.height);
[UIView transitionWithView:imgAnimationBase
duration:3.0f
options:NO
animations:^{
imgAnimationBase.image = [UIImage imageNamed:@"animation-2.jpg"];
[UIView animateWithDuration:3.0 animations:^{
imgAnimationBase.alpha = 1.0;
imgAnimationBase.transform =CGAffineTransformMakeScale(2,2);
}];
}
completion:^(BOOL finished) {
[UIView transitionWithView:imgAnimationBase
duration:3.0f
options:NO
animations:^{
imgAnimationBase.image = [UIImage imageNamed:@"animation-3.jpg"];
[UIView animateWithDuration:3.0 animations:^{
imgAnimationBase.alpha = 1.0;
imgAnimationBase.transform =CGAffineTransformMakeScale(1,1);
}];
}
completion:^(BOOL finished) {
}];
}];
}];
答案 0 :(得分:1)
正如评论中所述 - 当您已经在[UIView animateWithDuration: animations:]
区块时,无需再次拨打animations
。