详解IPhone动画效果类型及实现方法

移动开发 iOS
本文介绍的是详解IPhone动画效果类型及实现方法,主要是实现iphone中的动画效果,先来看内容详解。

详解IPhone动画效果类型及实现方法是本文要介绍的内容,主要介绍了iphone动画的实现方法,不多说,我们一起来看内容。

实现iphone漂亮的动画效果主要有两种方法,一种是UIView层面的,一种是使用CATransition进行更低层次的控制.

1、UIView

  1. CGContextRef context = UIGraphicsGetCurrentContext();  
  2. [UIView beginAnimations:nil context:context];  
  3. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
  4. [UIView setAnimationDelegate:self];  
  5. [UIView setAnimationDuration:1.0];          //动画持续的时间  
  6.  
  7. //这里添加你对UIView所做改变的代码  
  8.  
  9. //[UIView setAnimationDidStopSelector:@selector(animationFinished:)];   //动画停止后,执行某个方法  
  10. [UIView commitAnimations]; 

2、UIView(使用Cocoa Touch)

  1. CGContextRef context = UIGraphicsGetCurrentContext();  
  2. [UIView beginAnimations:nil context:context];  
  3. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
  4. [UIView setAnimationDuration:1.0];  
  5.  
  6. // Cocoa Touch    
  7. [UIView setAnimationTransition: UIViewAnimationTransitionCurlUp forView:myView cache:YES];  
  8.  
  9. [UIView setAnimationDelegate:self];  
  10. //[UIView setAnimationDidStopSelector:@selector(animationFinished:)]; //动画停止后,执行某个方法  
  11. [UIView commitAnimations];  
  12. 动画方式(UIViewAnimationTransition):  
  13.     UIViewAnimationTransitionFlipFromLeft              //从左向右翻转  
  14.     UIViewAnimationTransitionFlipFromRight             //从右向左翻转  
  15.     UIViewAnimationTransitionCurlUp                    //从下向上翻页  
  16.     UIViewAnimationTransitionCurlDown                  //从上向下翻页 

3、CATransition

  1. CATransition *animation = [CATransition animation];  
  2.      animation.delegate = self;  
  3.      animation.duration = 1.0f;       //动画执行时间  
  4.      animation.timingFunction = UIViewAnimationCurveEaseInOut;  
  5.      animation.type = kCATransitionFade;  
  6.      animation.subtype = kCATransitionFromRight;  
  7.       
  8. // 这里添加你对UIView所做改变的代码  
  9.  
  10. [[myView layer] addAnimation:animation forKey:@"animation"]; 

setType:有四种类型:

  1. kCATransitionFade                   //交叉淡化过渡                     
  2. kCATransitionMoveIn               //移动覆盖原图                     
  3. kCATransitionPush                    //新视图将旧视图推出去                     
  4. kCATransitionReveal                //底部显出来     

setSubtype:有四种类型:

  1. kCATransitionFromRight;                     
  2. kCATransitionFromLeft(默认值)                     
  3. kCATransitionFromTop;                     
  4. kCATransitionFromBottom          
  5. 注:kCATransitionFade 不支持Subtype      

4、CATransition(只使用setType,参数是NSString)    

  1. CATransition *animation = [CATransition animation];      
  2.  animation.delegate = self;       
  3.  animation.duration = 1.0f;   //动画执行时间       
  4.  animation.timingFunction = UIViewAnimationCurveEaseInOut;       
  5.  animation.type = @"suckEffect";// 这里添加你对UIView所做改变的代码       
  6.  [[myView layer] addAnimation:animation forKey:@"animation"];     

可以用的效果主要有:

  1. pageCurl     //向上翻一页       
  2. pageUnCurl   //向下翻一页        
  3. rippleEffect   //滴水效果        
  4. suckEffect     //收缩效果,如一块布被抽走     
  5. cube       //立方体效果      
  6. oglFlip      //上下翻转效果 

小结:详解IPhone动画效果类型及实现方法的内容介绍完了,希望本文对你有所帮助!

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

2011-07-08 10:15:15

IPhone 动画

2011-08-12 14:04:53

iPhone动画

2011-08-16 18:13:42

IPhone开发UIView动画

2011-08-10 14:40:23

iPhone动画

2011-08-09 13:50:01

iPhone动画UIView

2012-06-04 14:47:42

HTML5

2017-02-06 13:00:49

Android翻转卡片动画效果

2011-07-08 15:08:16

iPhone 图片

2011-07-22 18:20:04

IOS View 动画

2022-03-29 11:28:24

HarmonyOS动画css

2009-09-15 16:08:00

2012-05-22 09:21:10

数据中心PUEFacebook数据中

2012-05-21 14:36:18

Facebook开源

2011-08-15 13:50:06

IPhone开发UIView动画

2011-08-22 14:21:24

iPhone开发UIView Anim

2011-05-30 13:23:11

Android 动画

2011-07-20 15:20:14

IPhone AVAudioRec

2011-08-08 10:42:46

iPhone UITableVie 分页

2009-09-22 12:59:58

ibmdwDojo

2011-07-28 10:11:54

iPhone开发 备忘
点赞
收藏

51CTO技术栈公众号