home | create | search | help
  1. //This are some classes for Animation on Objective-c used in the iPhone.
  2. //.h class
  3.     IBOutlet UIView *mover;
  4.     IBOutlet UIView *grower;
  5.     IBOutlet UIView *flipper;
  6.     IBOutlet UIImageView *iv;
  7. }
  8. @property (nonatomic, retain) UIView *mover;
  9. @property (nonatomic, retain) UIView *grower;
  10. @property (nonatomic, retain) UIView *flipper;
  11. @property (nonatomic, retain) UIImageView *iv;
  12.  
  13. -(IBAction) move;
  14. -(IBAction) grow;
  15. -(IBAction) flip;
  16.  
  17. @end
  18. //.m class
  19. //just change the name to your buttons
  20. @synthesize mover, grower, flipper, iv;
  21.  
  22. - (IBAction) move {
  23.  
  24.     [UIView beginAnimations:nil context:NULL];
  25.    
  26.     [UIView setAnimationDuration:1.0];
  27.     [UIView setAnimationRepeatCount:10];
  28.     [UIView setAnimationRepeatAutoreverses:YES];
  29.    
  30.     CGPoint pos = mover.center;
  31.     pos.y = 220.0f;
  32.     mover.center = pos;
  33.    
  34.     [UIView commitAnimations];   
  35. }
  36.  
  37.  
  38. - (IBAction) grow {
  39.    
  40.     [UIView beginAnimations:nil context:NULL];
  41.    
  42.     [UIView setAnimationDuration:0.5];
  43.     [UIView setAnimationRepeatCount:5];
  44.     [UIView setAnimationRepeatAutoreverses:YES];
  45.     CGRect b = grower.bounds;
  46.     b.size.height = 200;
  47.     b.size.width = 200;
  48.     grower.bounds =  b;
  49.    
  50.     [UIView commitAnimations];   
  51. }
  52.  
  53. - (IBAction) flip {
  54.     [UIView beginAnimations:nil context:nil];
  55.  
  56.     [UIView setAnimationDuration:1];
  57.     [UIView setAnimationRepeatCount:5];
  58.     [UIView setAnimationRepeatAutoreverses:YES];
  59.    
  60.     flipper.backgroundColor = [UIColor blackColor];
  61.    
  62.     [UIView commitAnimations];
  63. }
  64.  
Subscribe to this code! Get Firefox! Valid XHTML Valid CSS Powered By GeSHi 665 pieces of code saved