iPhone开发中动画效果实现分类附代码


  本文标签:iPhone 动画

  iPhone开发中动画效果实现分类代码是本文要介绍的内容,但是内容不是很多,主要是以代码的形式来实现动画的分类,来看详细代码,希望对你帮助!

  1. {  
  2.     [UIView beginAnimations:nil context:nil];  
  3.     [UIView setAnimationRepeatCount:1];  
  4.     [UIView setAnimationDuration:1];  
  5.     [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];   
  6.     [UIView setAnimationDelegate:self];  
  7.     [UIView setAnimationDidStopSelector:@selector(resetView)];  
  8.       
  9.     CGAffineTransform oneTransform = CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180));  
  10.     CGAffineTransform twoTransform = CGAffineTransformTranslate(self.animatView.transform,0,-100);  
  11.     CGAffineTransform newTransform = CGAffineTransformConcat(oneTransform, twoTransform);  
  12.     [self.animatView setTransform:newTransform];  
  13.     [UIView commitAnimations];  
  14. }  
  15. - (void) second_animations  
  16. {  
  17.     CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];  
  18.     [animation setDuration:1];  
  19.     [animation setRepeatCount:0];  
  20.     [animation setAutoreverses:YES];//自动反向动画  
  21.     [animation setFromValue:[NSNumber numberWithFloat:1.0]];  
  22.     [animation setToValue:[NSNumber numberWithFloat:0]];  
  23.     [animation setDelegate:self];  
  24.     [self.animatView.layer addAnimation:animation forKey:@"firstView-Opacity"];  
  25. }  
  26. - (void) third_animations  
  27. {  
  28.     [UIView beginAnimations:nil context:nil];  
  29.     [UIView setAnimationRepeatCount:1];  
  30.     [UIView setAnimationDuration:1];  
  31.     [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];   
  32.     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.containView cache:YES];  
  33.     [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:)];  
  34.     [UIView commitAnimations];  
  35. }  
  36. - (void) fourth_animations  
  37. {  
  38.     CATransition *transition = [CATransition animation];  
  39.     transition.duration = 1.0f;           
  40.     transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];   
  41.     transition.type = @"pageCurl";  //@"cube" @"moveIn" @"reveal" @"fade"(default) @"pageCurl" 
  42. @"pageUnCurl" @"suckEffect" @"rippleEffect" @"oglFlip"  
  43.     transition.subtype = kCATransitionFromRight;  
  44.     transition.removedOnCompletion = YES;  
  45.     transition.fillMode = kCAFillModeBackwards;  
  46.     transition.delegate = self;  
  47.     [self.animatView.layer addAnimation:transition forKey:nil];    
  48. }  
  49. -(void) resetView  
  50. {  
  51.     [self.animatView setTransform:CGAffineTransformRotate(self.animatView.transform, degreesToRadian(180))];  
  52.     self.animatView.frame = CGRectMake(0, 0, 280, 200);  
  53. }  
  54. #pragma mark Delegate Methods  
  55. - (void)animationDidStop:(CAAnimation *) theAnimation finished:(BOOL) flag {  
  56.     self.animatView.frame = CGRectMake(0, 0, 280, 200);  
  57. }  
  58.  
  59. #define degreesToRadian(x) (M_PI * (x) / 180.0) 

  小结:iPhone开发中动画效果实现分类代码的内容介绍完了,希望通过本文的学习对你有所帮助!