• ios学习--详解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动画效果类型及实现方法的内容介绍完了,希望本文对你有所帮助

  • 相关阅读:
    计算两个字符串的最大公共字串的长度,字符不区分大小写
    任何一个整数m的立方都可以写成m个连续奇数之和。
    求一个byte数字对应的二进制数字中1的最大连续数
    Elasticsearch的过滤查询
    如何在Elasticsearch中安装中文分词器(IK+pinyin)
    使用Linux的alternatives命令替换选择软件的版本
    PHP如何与搜索引擎Elasticsearch交互?
    如何安装搜索引擎Elasticsearch?
    如何修改MAC自带的PHP的版本?
    程序员技能图谱
  • 原文地址:https://www.cnblogs.com/songfeixiang/p/3733678.html
Copyright © 2020-2023  润新知