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

移动开发 iOS
本文介绍的是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开发中动画效果实现分类代码的内容介绍完了,希望通过本文的学习对你有所帮助!

责任编辑:zhaolei 来源: 互联网
相关推荐

2011-08-12 14:04:53

iPhone动画

2011-07-08 10:15:15

IPhone 动画

2011-08-08 10:42:46

iPhone UITableVie 分页

2011-08-16 18:13:42

IPhone开发UIView动画

2011-08-22 14:21:24

iPhone开发UIView Anim

2010-09-10 09:57:27

DIV样式

2013-07-05 10:26:40

Android

2011-07-29 13:55:10

IPhone 动画

2011-07-08 15:08:16

iPhone 图片

2022-07-28 14:33:32

webviewweb页面

2011-07-22 18:20:04

IOS View 动画

2017-01-22 17:25:55

Android放大镜效果源码分析

2010-08-03 11:29:09

Flex全屏

2011-08-15 13:50:06

IPhone开发UIView动画

2011-08-15 11:23:41

iPhone开发循环滚动UIScrollVie

2009-12-25 14:25:39

WPF图标

2013-06-25 11:21:35

Android开发幻灯片效果Gallery

2010-09-10 14:33:32

SQL循环语句

2011-08-12 11:31:46

iPhoneUIView动画

2011-08-16 14:54:12

iphone开发APP
点赞
收藏

51CTO技术栈公众号