-1
我想用3个步骤创建动画。第一步应该放大照片上的正确方向。第二步是在3秒内放大其他图片的效果。最后一步是再次在3秒内用不同的图像缩小。我完全按照我的要求完成了前两步,但是当我添加3步时,一些事情出错了。它就像它试图做2和3步一起。请帮帮我。这是我的代码。我的UIView动画有什么问题?
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) {
}];
}];
}];
你为什么要在动画块中调用'[UIView animateWithDuration:animations:]'? – Losiowaty
啊,是的,谢谢@Losiowaty,我错误地插入它。它解决了这个问题。不敢相信这样的错误。写下来作为答案,我会标记它。 –