zoukankan      html  css  js  c++  java
  • 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动画效果类型及实现方法的内容介绍完了,希望本文对你有所帮助

  • 相关阅读:
    java中为什么notify()可能会导致死锁,而notifyAll()则不会
    java中wait()和sleep()的区别;notify()和notifyall()区别
    你不知道的Golang盲点汇总【持续更新】
    rsync性能终极优化【Optimize rsync performance】
    基于cephfs搭建高可用分布式存储并mount到本地
    检测代码潜在bug和质量之SonarQube
    玩透二叉树(Binary-Tree)及前序(先序)、中序、后序【递归和非递归】遍历
    好用到哭!8个技巧让Vim菜鸟变专家
    Golang fmt Printf 格式化参数手册/详解/说明
    淘宝滑动验证码研究
  • 原文地址:https://www.cnblogs.com/songfeixiang/p/3733678.html
Copyright © 2011-2022 走看看