Core Animation based on Quartz provides very simple ways to create special effects in your game or application.

The following shows how to create a Resize Effect of any UIView (e.g. UIButtonView, UIImageView etc.)

  1. +(void)resize:(UIView*)view to:(CGSize)size withDuration:(int) duration andSnapBack:(BOOL) snapBack
  2. {
  3.     // Prepare the animation from the old size to the new size
  4.     CGRect oldBounds = view.layer.bounds;
  5.     CGRect newBounds = oldBounds;
  6.     newBounds.size = size;
  7.     CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"bounds"];
  8.    
  9.    
  10.     // iOS
  11.     animation.fromValue = [NSValue valueWithCGRect:oldBounds];
  12.     animation.toValue = [NSValue valueWithCGRect:newBounds];
  13.    
  14.    
  15.     if(!snapBack)
  16.     {
  17.         // Update the layer's bounds so the layer doesn't snap back when the animation completes.
  18.         view.layer.bounds = newBounds;
  19.     }
  20.    
  21.     // Add the animation, overriding the implicit animation.
  22.     [view.layer addAnimation:animation forKey:@"bounds"];
  23. }