这样做UIView的动画

  1. // Hide the bar button and show the view  
  2. self.navigationItem.rightBarButtonItem = nil;  
  3. [self.view viewWithTag:101].alpha = 1.0f;  
  4.   
  5. // Bounce to 115% of the normal size  
  6. [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];  
  7. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
  8. [UIView setAnimationDuration:0.4f];  
  9. [self.view viewWithTag:101].transform = CGAffineTransformMakeScale(1.15f, 1.15f);  
  10. [UIView commitModalAnimations];  
  11.   
  12. // Return back to 100%  
  13. [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];  
  14. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
  15. [UIView setAnimationDuration:0.3f];  
  16. [self.view viewWithTag:101].transform = CGAffineTransformMakeScale(1.0f, 1.0f);  
  17. [UIView commitModalAnimations];  
  18.   
  19. // Pause for a second and appreciate the presentation  
  20. [NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0f]];  
  21.   
  22. // Slowly zoom back down and hide the view  
  23. [UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];  
  24. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
  25. [UIView setAnimationDuration:1.0f];  
  26. [self.view viewWithTag:101].transform = CGAffineTransformMakeScale(0.01f, 0.01f);  
  27. [UIView commitModalAnimations];  
  28.   
  29. // Restore the bar button  
  30. [self.view viewWithTag:101].alpha = 0.0f; 

你可能感兴趣的:(UIView)