1. - (void)leftClick {
  2. [UIView beginAnimations:nil context:nil];
  3. //display mode, slow at beginning and end
  4. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
  5. //动画时间
  6. [UIView setAnimationDuration:1.0f];
  7. //使用当前正在运行的状态开始下一段动画
  8. [UIView setAnimationBeginsFromCurrentState:YES];
  9. //给视图添加过渡效果
  10. [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:imageView cache:YES];
  11. [UIView commitAnimations];
  12. }
  13. - (void)rightClick {
  14. [UIView beginAnimations:nil context:nil];
  15. //display mode, slow at beginning and end
  16. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
  17. //动画时间
  18. [UIView setAnimationDuration:1.0f];
  19. //使用当前正在运行的状态开始下一段动画
  20. [UIView setAnimationBeginsFromCurrentState:YES];
  21. //给视图添加过渡效果
  22. [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:imageView cache:YES];
  23. [UIView commitAnimations];
  24. }
  25. - (void)upClick {
  26. [UIView beginAnimations:nil context:nil];
  27. //display mode, slow at beginning and end
  28. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
  29. //动画时间
  30. [UIView setAnimationDuration:1.0f];
  31. //使用当前正在运行的状态开始下一段动画
  32. [UIView setAnimationBeginsFromCurrentState:YES];
  33. //给视图添加过渡效果
  34. [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:imageView cache:YES];
  35. [UIView commitAnimations];
  36. }
  37. - (void)downClick {
  38. [UIView beginAnimations:nil context:nil];
  39. //display mode, slow at beginning and end
  40. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
  41. //动画时间
  42. [UIView setAnimationDuration:1.0f];
  43. //使用当前正在运行的状态开始下一段动画
  44. [UIView setAnimationBeginsFromCurrentState:YES];
  45. //给视图添加过渡效果
  46. [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:imageView cache:YES];
  47. [UIView commitAnimations];
  48. }
  49. /*
  50. CATransition的type属性
  51. 1.#define定义的常量
  52. kCATransitionFade   交叉淡化过渡
  53. kCATransitionMoveIn 新视图移到旧视图上面
  54. kCATransitionPush   新视图把旧视图推出去
  55. kCATransitionReveal 将旧视图移开,显示下面的新视图
  56. 2.用字符串表示
  57. pageCurl            向上翻一页
  58. pageUnCurl          向下翻一页
  59. rippleEffect        滴水效果
  60. suckEffect          收缩效果,如一块布被抽走
  61. cube                立方体效果
  62. oglFlip             上下翻转效果
  63. */
  64. - (void)MyCAnimation1 {
  65. CATransition *animation = [CATransition animation];
  66. //动画时间
  67. animation.duration = 1.0f;
  68. //display mode, slow at beginning and end
  69. animation.timingFunction = UIViewAnimationCurveEaseInOut;
  70. //过渡效果
  71. animation.type = kCATransitionMoveIn;
  72. //过渡方向
  73. animation.subtype = kCATransitionFromTop;
  74. //添加动画
  75. [imageView.layer addAnimation:animation forKey:nil];
  76. }
  77. - (void)MyCAnimation2 {
  78. CATransition *animation = [CATransition animation];
  79. //动画时间
  80. animation.duration = 1.0f;
  81. //display mode, slow at beginning and end
  82. animation.timingFunction = UIViewAnimationCurveEaseInOut;
  83. //在动画执行完时是否被移除
  84. animation.removedOnCompletion = NO;
  85. //过渡效果
  86. animation.type = @"pageCurl";
  87. //过渡方向
  88. animation.subtype = kCATransitionFromRight;
  89. //暂时不知,感觉与Progress一起用的,如果不加,Progress好像没有效果
  90. animation.fillMode = kCAFillModeForwards;
  91. //动画停止(在整体动画的百分比).
  92. animation.endProgress = 0.7;
  93. [imageView.layer addAnimation:animation forKey:nil];
  94. }
  95. - (void)MyCAnimation3 {
  96. CATransition *animation = [CATransition animation];
  97. //动画时间
  98. animation.duration = 1.0f;
  99. //display mode, slow at beginning and end
  100. animation.timingFunction = UIViewAnimationCurveEaseInOut;
  101. //过渡效果
  102. animation.type = @"pageUnCurl";
  103. //过渡方向
  104. animation.subtype = kCATransitionFromRight;
  105. //暂时不知,感觉与Progress一起用的,如果不加,Progress好像没有效果
  106. animation.fillMode = kCAFillModeBackwards;
  107. //动画开始(在整体动画的百分比).
  108. animation.startProgress = 0.3;
  109. [imageView.layer addAnimation:animation forKey:nil];
  110. }
  111. - (void)MyCAnimation4 {
  112. [NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(updateButterfly) userInfo:nil repeats:YES];
  113. }
  114. - (void)updateButterfly {
  115. butterflyView.animationDuration = 0.75f;
  116. [self.view addSubview:butterflyView];
  117. [butterflyView startAnimating];
  118. butterflyView.center = [butterflyView randomCenterInView:self.view withInset:10.0f];
  119. }
  120. CATransition比较强大,一般可以使用CATransition模拟UIView的动画。

         /*  过渡效果
         fade     //交叉淡化过渡(不支持过渡方向)
         push     //新视图把旧视图推出去
         moveIn   //新视图移到旧视图上面
         reveal   //将旧视图移开,显示下面的新视图
         cube     //立方体翻滚效果
         oglFlip  //上下左右翻转效果
         suckEffect   //收缩效果,如一块布被抽走(不支持过渡方向)
         rippleEffect //滴水效果(不支持过渡方向)
         pageCurl     //向上翻页效果
         pageUnCurl   //向下翻页效果
         cameraIrisHollowOpen  //相机镜头打开效果(不支持过渡方向)
         cameraIrisHollowClose //相机镜头关上效果(不支持过渡方向)
        
    */

       

        
    /*
     过渡方向
         fromRight;
         fromLeft;
         fromTop;
         fromBottom;
        
    */

    CATransition *animation = [CATransition animation];

    animation.
    delegate = self;

    animation.duration = 
    0.5f; 
    //
    动画时长

    animation.timingFunction = UIViewAnimationCurveEaseInOut;

    animation.fillMode = kCAFillModeForwards;

    animation.type = 
    @"
    cube
    "; 
    //
    过度效果

    animation.subtype = 
    @"
    formLeft
    "; 
    //
    过渡方向

    animation.startProgress = 
    0.0 
    //
    动画开始起点(在整体动画的百分比)

    animation.endProgress = 
    1.0;  
    //
    动画停止终点(在整体动画的百分比)

    animation.removedOnCompletion = NO;

    [self.view.layer addAnimation:animation forKey:
    @"
    animation
    "];

CATransition类动画的更多相关文章

  1. iOS开发CAAnimation类动画, CATransition动画

    #pragma mark - CAAnimation类.实现动画 #pragma mark ** CABasicAnimation 动画 - (IBAction)handleCABasicAnimat ...

  2. Keyframe类-动画中关键帧概念

    package com.loaderman.customviewdemo; import android.animation.Animator; import android.animation.Ke ...

  3. CATransition的动画效果类型及实现方法--老代码备用参考

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

  4. CoreAnimation笔记

    核心动画继承结构 CoreAnimation Core Animation是直接作用在CALayer上的(并非UIView上)非常强大的跨Mac OS X和iOS平台的动画处理API,Core Ani ...

  5. 动画浅析-CAAnimation和CATransition

      出处: http://blog.csdn.net/mad2man/article/details/17260887   //动画播放完之后不恢复初始状态 baseAnimation.removed ...

  6. CATransition转场动画

    背景: 最近在温习动画,分享个简单系统的转场动画 viewcontroller *VC=[self.storyboard instantiateViewControllerWithIdentifier ...

  7. core Animation之CATransition(转场动画)

    用于做转场动画,能够为层提供移出屏幕和移入屏幕的动画效果.iOS比Mac OS X的转场动画效果少一点 UINavigationController就是通过CATransition实现了将控制器的视图 ...

  8. jQuery - 02. 样式表属性操作/类操作、动画、显示隐藏、滑入、淡入、停止动画、节点操作、添加对象、清空节点

    样式表属性操作.css $("div").css({'width':100,'height':100,'background':'red'}); $("div" ...

  9. iOS开发之各种动画各种页面切面效果

    因工作原因,有段时间没发表博客了,今天就发表篇博客给大家带来一些干货,切勿错过哦.今天所介绍的主题是关于动画的,在之前的博客中也有用到动画的地方,今天就好好的总结一下iOS开发中常用的动画.说道动画其 ...

随机推荐

  1. Git存储用户名和密码(明文需谨慎)

    当你配置好git后,在C:\Documents and Settings\Administrator\ 目录下有一个 .gitconfig 的文件,里面会有你先前配好的name 和email,只需在下 ...

  2. jira 解决结果配置

    jira 的配置比较繁琐,有很多的小细节,使用中出现了各种小问题,总结梳理下 1.解决结果 问题1:编辑了任务后,解决结果变成了已解决 找到编辑任务所对应的界面方案,将解决结果字段从界面配置里移除 问 ...

  3. Fidder 工具使用

    Fiddler是最强大最好用的Web调试工具之一,它能记录所有客户端和服务器的http和https请求,允许你监视,设置断点,甚至修改输入输出数据. 使用Fiddler无论对开发还是测试来说,都有很大 ...

  4. GMTED2010 高程数据下载

    http://topotools.cr.usgs.gov/GMTED_viewer/viewer.htm

  5. C语言-字符编码转换:UTF与GB2312

    依赖库libiconv,libiconv库的交叉编译不做描述,网上很多 #include <stdio.h> #include <stdlib.h> #include < ...

  6. JAVA I/O使用方法(转)

    下面四张图表明了类之间的继承关系,其中红色.加粗的类名是常用的类. 常用转换 FileReader——>BufferedReader BufferedReader in= new Buffere ...

  7. Unix/Linux环境C编程入门教程(12) openSUSECCPP以及Linux内核驱动开发环境搭建

    1. openSUSE是一款优秀的linux. 2.选择默认虚拟机 3.选择稍后安装操作系统 4.选择linux  opensuse 5. 选择默认虚拟机名称 6.设置处理器为双核. 7.内存设置为2 ...

  8. 2016 Multi-University Training Contest 4 总结

    第四场多校队伍的发挥还是相当不错的. 我倒着看题,发觉最后一题树状数组可过,于是跟队友说,便开始写,十分钟AC. 欣君翻译01题给磊哥,发现是KMP裸题,但是发现模板太旧,改改后过了. 11题是一道毒 ...

  9. Oracle_用户管理

    创建用户: CREATE USER user   --创建用户user IDENTIFIED {BY password | EXTERNALLY}  --设备用户密码,EXTERNALLY说用该用户由 ...

  10. C++中的句柄类

    初次在<C++ Primer>看到句柄,不是特别理解.在搜索相关资料后,终于有了点头绪. 首先明白句柄要解决什么问题.参考文章<C++ 沉思录>阅读笔记——代理类 场景: 我们 ...