Showing posts with label UIViewAnimation. Show all posts
Showing posts with label UIViewAnimation. Show all posts

Wednesday, February 15, 2012

How to create wiggle animation for your UIView ?

So you wondering about how to create the world famous wiggling action in your app.

Wiggling action is what happens when you long press on icons on your iPhone/iPad screen and they start dancing. Here is the code:

   CATransform3D transform = CATransform3DMakeRotation(0.08, 0, 0, 1.0);  
   CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];  
   animation.toValue = [NSValue valueWithCATransform3D:transform];  
   animation.autoreverses = YES;   
   animation.duration = 0.1;   
   animation.repeatCount = 10000;   
   animation.delegate=self;  
   [[self layer] addAnimation:animation forKey:@"wiggleAnimation"];