Cocoa in the Shell

[iOS] Ripple effect

I often get asked how the ripple effect is done in MacG Mobile when the news get refreshed, and is it difficult to do ? Well since people don’t seem to be able to type iphone SDK ripple effect in Google, I will post the solution… and it’s really easy since it’s just a constant, but it’s not documented.

So basically when you want an animation in a view you do something like this :

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:view cache:NO];
[UIView commitAnimations];

And this will flip your view.

To make a ripple effect, you just have to pass 110 for the first parameter of setAnimationTransition: and there it is, you have it.
If you pass 103 you will have the nice suck effect like in the Mail app when you delete a message.

For more effects you can check this link.

Tags: ,