I have an animation that bounces a view slightly along the x axis. The problem is that is is using the old animation mechanism and as the documentation states use of block based animations are recommended for iOS4+. I’m wondering how I can turn this simple animation into a block based animation:
[UIView beginAnimations:@"bounce" context:nil];
[UIView setAnimationRepeatCount:2];
[UIView setAnimationRepeatAutoreverses:YES];
self.view.center = CGPointMake(self.view.center.x + 10, self.view.center.y);
[UIView commitAnimations];
Also I want the view to return to its starting position after the animation ends, the method above bounces the view and increments its x value by 10 pixels.
Thanks for any help.
Block-base animation’s format is like this:
And the code below bounces the view
twiceandgo back to origin position, maybe there exists a better way:And this one is similar, but
go back to origin position not smoothly.