下面是实现的代码

//选择动画

- (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. 通过 txt 文件批量导入需要批量处理的数据的标识字段

    前言 在一些工作中,可能需要对数据库中的一些数据(批量)进行处理(修改或者查询),而数据的来源是你的同事,换句话说就是这批数据不可能通过某些查询条件查出来, 而这批数据又比较多,比如几百.几千甚至几万 ...

  2. OO的奇妙冒险1

    OO的奇妙冒险 ~OOP入门与字符串处理~ 目录 总体分析 作业内容分析 作业内容总结 互测的收获 公测互测bug分析与总结 不太正经的个人自嗨 总体分析 公测 中测(基础与进阶): 其实在我看来,从 ...

  3. 【分享】JS如何为复制的Web文本添加其他信息

    看到了两篇关于这题的讨论,简单的记录一下!o(* ̄▽ ̄*)ブ 1.  stackoverflow , How to add extra info to copied web text 2.  黑客派, ...

  4. Python 计算π及进度条显示

    一,首先打开命令提示符找到Python路径,输入pip install tqdm下载第三方库tpdm. 二,写程序 法一 from math import * from tqdm import tqd ...

  5. JavaScript超酷时钟的制作

    <!DOCTYPE html PUBLIC "-//W3C//h2D XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. Unity实现用户条款弹窗及登录

    首先来看效果图... 1.先编辑页面 1)新建登录按钮,更名为Login 2)新建toggle,新建方式如下图 调整toggle的大小和位置到适当的范围. 3)新建同意用户条款按钮,步骤为新建UI-& ...

  7. 操作日志的设计小结by大熊

    一.首先由同事的操作日志说起 同事做了一个这样的操作日志,他定义系统所有发的json加入这两个字段,module和msg,然后在service里面用注解@Log拦截,即可记录对应的操作日志. { mo ...

  8. Django--Managers

    Django--Managers Manager 概念: 1.Manager是Django中的数据模型,可以通过manager进行对数据库的查询操作.可以看其结构它本身是一个空的类,其主要的功能来自于 ...

  9. mpeg4文件分析(纯c解析代码)

    参考链接: 1. MPEG4码流的帧率计算 https://blog.csdn.net/littlebee90/article/details/68924690                2. M ...

  10. Windows挂载NFS共享盘

    Centos7添加NFS方法请见如下链接: https://www.cnblogs.com/jackyzm/p/10285845.html 一:添加NFS服务 1.1:此电脑-右键-管理-window ...