2010-01-12 51 views
0

我有一些代码,很好地工作,并像单击按钮时出现的菜单一样。我只是想略微动画。所以,当它出现时,它出现在反弹。下面是这表明它弹跳图像进入查看

[UIView beginAnimations:@"theAnimation" context:NULL]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(yourAnimationHasFinished:finished:context:)]; 
[UIView setAnimationDuration: 0.3]; 
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0, -20); 
scrollChangeClothing.transform = moveUp; 
imgClothesMenuBg.transform = moveUp; 
[UIView commitAnimations]; 

[UIView beginAnimations:@"theAnimation" context:NULL]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDidStopSelector:@selector(yourAnimationHasFinished:finished:context:)]; 
[UIView setAnimationDuration: 0.1]; 
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0, 0); 
scrollChangeClothing.transform = moveUp; 
imgClothesMenuBg.transform = moveUp; 
[UIView commitAnimations]; 

上面的代码(我认为)应该首先显示的图像在-20像素的起点,然后沉降回到它的原点的代码。

我试过将转换命令组合起来,但那也没用。我是否需要在setAnimationDidStopSelector中放置第二个动画?所以一旦完成,它会反弹?

回答

1

我认为你的代码不起作用,因为两个动画块在场景后面合并成一个标识转换。

  • 尝试从第一个块除去了UIView动画的方法,只留下下面的行。这应该让你的观点“滑入位置”。

    CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0,-20); scrollChangeClothing.transform = moveUp; imgClothesMenuBg.transform = moveUp;

  • 如果您确实需要动画“滑出”,请尝试将两个块封闭在外部+ beginAnimations:context:/ + commitAnimations块中。

0

是的,您应该将第二个动画块移动到第一个animationDidStop方法中。