在反弹的图片查看 [英] bounce an image in to view
问题描述
我有一些code这很好地工作,其作用就像当你点击一个按钮,出现一个菜单。我只是想稍微动画。所以,当它出现时,它出现在反弹。这里的code这表明它
I have some code which works nicely and acts like a menu appearing when you click a button. I just want to animate slightly. So when it appears, it appears to bounce in. Here's the code which shows it
[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];
在code以上(我认为)应该首先表明,在-20像素的图像起点,然后定居回到它的原点。
the code above (I thought) should first show the image at -20 pixels start point, then settle back to it's original point.
我想无论是相结合的变换命令,但没有工作。我需要把第二个动画的setAnimationDidStopSelector?因此,一旦它的完成,它就会反弹?
I tried combining the transform commands but that didnt work either. Do I need to put the second animation in the setAnimationDidStopSelector?? So once it's finished, it will then bounce?
推荐答案
我觉得你的code不起作用,因为这两个动画块合并幕后到一个恒等变换。
I think your code doesn't work because the two animation blocks are coalesced behind the scene into one identity transform.
-
尝试从第一块取出的UIView动画的方法,下面只留下线条。这应该使你的观点滑入地位。
Try removing the UIView animation methods from the first block, leaving only the lines below. This should make your views "slide into position".
CGAffineTransform为moveUp = CGAffineTransformMakeTranslation(0,-20);
scrollChangeClothing.transform =为moveUp;
imgClothesMenuBg.transform =为moveUp;
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0, -20); scrollChangeClothing.transform = moveUp; imgClothesMenuBg.transform = moveUp;
在尝试在外+ beginAnimations围绕这两个块:上下文:/ + commitAnimations块,如果你确实需要动画滑出
Try enclosing both blocks in an outer +beginAnimations:context:/+commitAnimations block if you do need to animate "sliding out".
这篇关于在反弹的图片查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!