iOS CATransition 动画的简单使用
下面是实现的代码
//选择动画
- (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 动画的简单使用的更多相关文章
- iOS中动画的简单使用
iOS中的动画右两大类1.UIView的视图动画2.Layer的动画 UIView的动画也是基于Layer的动画动画的代码格式都很固定 1.UIView动画 一般方式[UIView beginAnim ...
- [iOS]过渡动画之高级模仿 airbnb
注意:我为过渡动画写了两篇文章:第一篇:[iOS]过渡动画之简单模仿系统,主要分析系统简单的动画实现原理,以及讲解坐标系.绝对坐标系.相对坐标系,坐标系转换等知识,为第二篇储备理论基础.最后实现 Ma ...
- iOS block-base 动画简单用法+关键帧动画设置线性变化速度的问题
本文转载至 http://www.tuicool.com/articles/aANBF3m 时间 2014-12-07 20:13:37 segmentfault-博客原文 http://segm ...
- iOS开发——动画编程Swift篇&(三)CATransition动画
CATransition动画 // MARK: - CATransition动画 // /* 动画样式 */ // let kCATransitionFade: NSString! //翻页 // l ...
- iOS开发CAAnimation类动画, CATransition动画
#pragma mark - CAAnimation类.实现动画 #pragma mark ** CABasicAnimation 动画 - (IBAction)handleCABasicAnimat ...
- IOS 动画专题 --iOS核心动画
iOS开发系列--让你的应用“动”起来 --iOS核心动画 概览 通过核心动画创建基础动画.关键帧动画.动画组.转场动画,如何通过UIView的装饰方法对这些动画操作进行简化等.在今天的文章里您可以看 ...
- ios 学习动画的套路 (一)
你也肯定喜欢炫酷的动画! 在APP中,动画就是一个点睛之笔!可以给用户增加一些独特的体验感,估计也有许多的和我一样的,看着那些觉得不错的动画,也就只能流口水的孩子,毕竟~不知道从哪里下手去写!会连续的 ...
- ios基础动画、关键帧动画、动画组、转场动画等
概览 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥iOS动画全貌.在这里你可以看到iOS中如何使用图层精简非交互式绘图,如何通过核心动画创建基础动画.关键帧动画 ...
- iOS 核心动画 Core Animation浅谈
代码地址如下:http://www.demodashi.com/demo/11603.html 前记 关于实现一个iOS动画,如果简单的,我们可以直接调用UIView的代码块来实现,虽然使用UIVie ...
随机推荐
- canvas和SVG
Canvas的介绍 1.1.创建canvas元素 canvas的定义:它是HTML5中新增一个HTML5标签与操作canvas的javascript API,它可以实现在网页中完成动态的2D与3D图像 ...
- echarts x和y去掉
解决方法 "axisLine": { "show": false },
- JS-3
运算符 数学运算符 + - * / %(取模运算符) js内置一个对象叫Math,Math提供了很多关于计算的方法,常见的 // 随机数 console.log(Math.random()); // ...
- 整数中x出现的次数
求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数?为此他特别数了一下1~13中包含1的数字有1.10.11.12.13因此共出现6次,但是对于后面问题他就没辙了.ACMer ...
- tensorflow:保存与读取网络结构,参数
训练一个神经网络的目的是啥?不就是有朝一日让它有用武之地吗?可是,在别处使用训练好的网络,得先把网络的参数(就是那些variables)保存下来,怎么保存呢?其实,tensorflow已经给我们提供了 ...
- 单链表ADT
本博客第一篇学术性博客,所以还是写点什么东西: 首先这篇博客以及以后的博客中的代码尽量百分之90是自己写过的: 可能有部分图片和代码是我认为别人更好的故摘抄下来, 本人三观正确,所以一定会表明来源: ...
- cocoaPods安装爬坑总结
1.移除现有Ruby默认源 $ gem sources --remove https://rubygems.org/ 2.使用新的源 $ gem sources -a https://ruby.t ...
- HFun.快速开发平台(四)=》自定义列表实例(请求参数的处理)
上编自定义列表描述了自定义列表的基本实现功能,本此记录列表的请求过程. 个人比较喜欢对参数进行对象化,方便后续人维护及查看,先上代码: /******************************* ...
- 命令提示符出现-bash-4.1$如何解决
故障原因:用户模式/etc/skel内容丢失 解决方法 复制etc/skel里内容到当前用户 [root@web01 ~]# su - test -bash-4.1$ cp /etc/skel/.ba ...
- hosts 添加主机和ip映射
背景:在服务器搭建环境时,迁移项目后,停止服务出现以下问题. 原因:项目停止或启动找不到映射名称或服务. 解决:修改hosts文件.hosts文件地址 /etc/hosts 添加主机和 ...