下面是实现的代码

//选择动画

- (IBAction)selectAnimationTypeButton:(id)sender {

UIButton *button = sender;

animationType animationType = button.tag;

NSString *subtypeString;

switch (_subType) {

case 0:

subtypeString = kCATransitionFromLeft;

break;

case 1:

subtypeString = kCATransitionFromBottom;

break;

case 2:

subtypeString = kCATransitionFromRight;

break;

case 3:

subtypeString = kCATransitionFromTop;

break;

default:

break;

}

_subType += 1;

if (_subType > 3) {

_subType = 0;

}

switch (animationType) {

case Fade:

[self transitionWithType:kCATransitionFade withSubtype:subtypeString forView:self.view];

break;

case Push:

[self transitionWithType:kCATransitionPush withSubtype:subtypeString forView:self.view];

break;

case Reveal:

[self transitionWithType:kCATransitionReveal withSubtype:subtypeString forView:self.view];

break;

case MoveIn:

[self transitionWithType:kCATransitionMoveIn withSubtype:subtypeString forView:self.view];

break;

case Cube:

[self transitionWithType:@"cube" withSubtype:subtypeString forView:self.view];

break;

case SuckEffect:

[self transitionWithType:@"suckEffect" withSubtype:subtypeString forView:self.view];

break;

case OgleFlip:

[self transitionWithType:@"oglFlip" withSubtype:subtypeString forView:self.view];

break;

case RippleEffect:

[self transitionWithType:@"rippleEffect" withSubtype:subtypeString forView:self.view];

break;

case PageCurl:

[self transitionWithType:@"pageCurl" withSubtype:subtypeString forView:self.view];

break;

case pageUnCurl:

[self transitionWithType:@"pageUnCurl" withSubtype:subtypeString forView:self.view];

break;

case CameraIrisHollowOpen:

[self transitionWithType:@"cameraIrisHollowOpen" withSubtype:subtypeString forView:self.view];

break;

case CameraIrisHollowClose:

[self transitionWithType:@"cameraIrisHollowClose" withSubtype:subtypeString forView:self.view];

break;

case CurlDow:

[self animationWithView:self.view withAnimationTransition:UIViewAnimationTransitionCurlDown];

break;

case CurlUp:

[self animationWithView:self.view withAnimationTransition:UIViewAnimationTransitionCurlUp];

break;

case FlipFromLeft:

[self animationWithView:self.view withAnimationTransition:(UIViewAnimationTransitionFlipFromLeft)];

break;

case FlipFromRight:

[self animationWithView:self.view withAnimationTransition:(UIViewAnimationTransitionFlipFromRight)];

break;

default:

break;

}

static int i = 1;

if (i > 6) {

i = 1;

}

[self addBackgroundImgWithName:[NSString stringWithFormat:@"0%d.jpg",i]];

i += 1;

}

#pragma CATransition========动画实现=======

- (void)transitionWithType:(NSString*) type withSubtype:(NSString*)subType forView:(UIView*)view{

//创建CATranstion对象

CATransition *animation = [CATransition animation];

//设置运动时间

animation.duration = DURATION;

//设置动画的类型type

animation.type = type;

if (subType != nil) {

//设置子类

animation.subtype = subType;

}

//设置动画出现的时候的运动速度

animation.timingFunction = UIViewAnimationOptionCurveEaseInOut;

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

}

#pragma mark ============UIView动画实现=============

- (void)animationWithView:(UIView*)view withAnimationTransition:(UIViewAnimationTransition)transtion{

[UIView animateWithDuration:DURATION animations:^{

[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

[UIView setAnimationTransition:transtion forView:view cache:YES];

}];

}

- (void)addBackgroundImgWithName:(NSString*)imgeName{

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:imgeName]];

}

代码放到github上,喜欢就给个Star:https://github.com/JakeTorres/Jake-sHouse

iOS CATransition 动画的简单使用的更多相关文章

  1. iOS中动画的简单使用

    iOS中的动画右两大类1.UIView的视图动画2.Layer的动画 UIView的动画也是基于Layer的动画动画的代码格式都很固定 1.UIView动画 一般方式[UIView beginAnim ...

  2. [iOS]过渡动画之高级模仿 airbnb

    注意:我为过渡动画写了两篇文章:第一篇:[iOS]过渡动画之简单模仿系统,主要分析系统简单的动画实现原理,以及讲解坐标系.绝对坐标系.相对坐标系,坐标系转换等知识,为第二篇储备理论基础.最后实现 Ma ...

  3. iOS block-base 动画简单用法+关键帧动画设置线性变化速度的问题

    本文转载至 http://www.tuicool.com/articles/aANBF3m 时间 2014-12-07 20:13:37  segmentfault-博客原文  http://segm ...

  4. iOS开发——动画编程Swift篇&(三)CATransition动画

    CATransition动画 // MARK: - CATransition动画 // /* 动画样式 */ // let kCATransitionFade: NSString! //翻页 // l ...

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

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

  6. IOS 动画专题 --iOS核心动画

    iOS开发系列--让你的应用“动”起来 --iOS核心动画 概览 通过核心动画创建基础动画.关键帧动画.动画组.转场动画,如何通过UIView的装饰方法对这些动画操作进行简化等.在今天的文章里您可以看 ...

  7. ios 学习动画的套路 (一)

    你也肯定喜欢炫酷的动画! 在APP中,动画就是一个点睛之笔!可以给用户增加一些独特的体验感,估计也有许多的和我一样的,看着那些觉得不错的动画,也就只能流口水的孩子,毕竟~不知道从哪里下手去写!会连续的 ...

  8. ios基础动画、关键帧动画、动画组、转场动画等

    概览 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥iOS动画全貌.在这里你可以看到iOS中如何使用图层精简非交互式绘图,如何通过核心动画创建基础动画.关键帧动画 ...

  9. iOS 核心动画 Core Animation浅谈

    代码地址如下:http://www.demodashi.com/demo/11603.html 前记 关于实现一个iOS动画,如果简单的,我们可以直接调用UIView的代码块来实现,虽然使用UIVie ...

随机推荐

  1. Struts 2中如何解决中文乱码问题?

    在配置文件中定义如下常量值配置: <constant name=”struts.i18n.encoding” value=”UTF-8”/> 注意:只能解决post请求的乱码问题,针对ge ...

  2. 洛谷P1439 【模板】最长公共子序列

    题目描述 给出1-n的两个排列P1和P2,求它们的最长公共子序列. 输入输出格式 输入格式: 第一行是一个数n, 接下来两行,每行为n个数,为自然数1-n的一个排列. 输出格式: 一个数,即最长公共子 ...

  3. Apache Spark 3.0 将内置支持 GPU 调度

    如今大数据和机器学习已经有了很大的结合,在机器学习里面,因为计算迭代的时间可能会很长,开发人员一般会选择使用 GPU.FPGA 或 TPU 来加速计算.在 Apache Hadoop 3.1 版本里面 ...

  4. 本人亲身讲解本科期间学习Linux系统过程

    学习Linux也有一段时间了,回首这段时光,既迷茫过也既充实过.当时刚接触Linux是在大学,身边的同学都在学习,我想我也该学点一技之长了.我本科并不是计算机专业的,关于软件的课程也就只有C++,所以 ...

  5. WPF拖动总结

    https://www.cnblogs.com/DebugLZQ/archive/2013/05/07/3062733.html <Window xmlns="http://schem ...

  6. 使用后台的limit 控制每页的容量

    和上一个不使用limit的不同,如果不使用后台的限制,那么就必须自己定义一个计算属性,并且v-for这个计算的数组,而如果要用到后台的限制,那么就不需要自己计算,v-for的直接就是后台获取的数组 1 ...

  7. 201671010142 <<面向对象程序设计(Java) 实验十五 线程 感悟和总结>>

    继承Thread类实现多线程 继承Thread类的方法尽管被我列为一种多线程实现方式,但Thread本质上也是实现了Runnable接口的一个实例,它代表一个线程的实例,并且,启动线程的唯一方法就是通 ...

  8. Create Maximum Number

    Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum numb ...

  9. namespace的作用

    namespace的用法 1.什么是命名空间 通常我们学c++的时候经常看见头文件下有一句using namespace std,有什么用呢? 例如: #include<iostream> ...

  10. 运行python脚本时,报错InsecurePlatformWarning: A true SSLContext object is not available,解决方法

    今天,要在新环境里运行一个python脚本,遇到下面的报错: /usr/lib/python2.7/site-packages/urllib3/util/ssl_.py:160: InsecurePl ...