下面是实现的代码

//选择动画

- (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. centos版本位数查看

    查看版本 cat /etc/issue cat /etc/redhat-release 查看位数 uname -a cat /proc/version   1. getconf LONG_BIT or ...

  2. EXCE 表格导入导出遇到问题(easypoi)

    使用Easypoi进行excel表格的导入导出遇到的问题: 1.导出时候打开文件一直遇乱码,主要的原因就是我在实体类没有进行给每个字段进行注解,就会导致每个字段找不到对应的汉字表头,所以一定不要忘了导 ...

  3. element-- 修改MessageBox 弹框 中确定和取消按钮顺序

    需求:修改弹框中的 取消/确定按钮顺序,及头部和底部背景颜色; 原ui效果图 需求ui效果图 方法:对取消及确定按钮自定义类名,样式重写

  4. Python3+Django get/post请求实现教程

    一.说明 之前写了一篇“Python3+PyCharm+Django+Django REST framework开发教程”,想着直接介绍rest就完了.但回过头来看,一是rest在解耦的同时将框架复杂 ...

  5. 卡方分布(Chi-Square Distribution):

    定义:如果我们的随机变量是标准正态分布(详见以前博客的高斯分布),那么多个随机变量的平方和服从的分布即为卡方分布. X=Y12+Y22+⋯+Yn2 其中,Y1,Y2,⋯,Yn均为服从标准正态分布的随机 ...

  6. mysql数据库的基本操作命令总结

    本文章将讲述Mysql数据的的基本操作.前期的安装请自行百度 运行环境:linux Ubuntu 16.04 命令行连接 在工作中主要使用命令操作方式,要求熟练编写 打开终端,运行命令 mysql - ...

  7. 对羊车门的思考/python/

    作业完成人: 学号:20181603048,温晨阳 学号:20181603024,刘鑫垚 题目描述:有3扇关闭的门,一扇门后面停着汽车,其余门后是山羊,只有主持人知道每扇门后面是什么.参赛者可以选择一 ...

  8. java web中验证码生成的demo

    首先创建一个CaptailCode类 package com.xiaoqiang.code; import java.awt.*; import java.awt.font.FontRenderCon ...

  9. Dubbo源码构建

    代码签出 通过以下的这个命令签出最新的项目源码: git clone https://github.com/apache/incubator-dubbo.git dubbo 分支 我们使用 maste ...

  10. netty解码器详解(小白也能看懂!)

    什么是编解码器? 首先,我们回顾一下netty的组件设计:Netty的主要组件有Channel.EventLoop.ChannelFuture.ChannelHandler.ChannelPipe等. ...