弹回图像进行查看

时间:2010-01-12 12:12:38

标签: iphone animation uiimageview

我有一些代码很好用,就像点击按钮时出现的菜单一样。我只想稍微动画一下。因此,当它出现时,它似乎反弹。这是显示它的代码

[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中吗?一旦它完成,它会反弹吗?

2 个答案:

答案 0 :(得分:1)

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

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

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

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

答案 1 :(得分:0)

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

相关问题