iPhone – UiView frame originated animation with rebound effect

When I moved frame.origin.x from x to x-200, I managed to animate my UIView; however, when frame.origin.x reached x-200 , I hope it can bounce back and forth.

Any hints on what should I do?
Thank you

int targetX = 200;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.1 ];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

myView.frame = CGRectMake(targetX, 0, [myView frame].size.width , [myView frame].size.height);
[UIView commitAnimations];

I believe you need to do a path animation. For a simple tutorial on this, please refer to: http://www.bdunagan.com/2009/04/26/core-animation-on-the-iphone/.

< /p>

Basic animation is just to animate between one point and another point, and there are some speed changes (easy to enter, ease out). Path animation can do curve, direction change, etc.

< /div>

When I moved frame.origin.x from x to x-200, I managed to animate my UIView; however, when frame.origin.x reached x-200, I hope it can bounce back and forth.

Any hints on what I should do?
Thank you

int targetX = 200;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.1 ];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

myView.frame = CGRectMake(targetX, 0, [myView frame].size.width , [myView frame].size.height);
[UIView commitAnimations];

I believe you need to do a path animation. About this For a simple tutorial, please refer to: http://www.bdunagan.com/2009/04/26/core-animation-on-the-iphone/.

Basic animation is just at one point Animate between and another point, and there are some speed changes (easy to enter, ease out). Path animation can be curve, direction change, etc.

Leave a Comment

Your email address will not be published.