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 ...
随机推荐
- iframe的缺点
*iframe会阻塞主页面的Onload事件: *搜索引擎的检索程序无法解读这种页面,不利于SEO; *iframe和主页面共享连接池,而浏览器对相同域的连接有限制,所以会影响页面的并行加载. 使用i ...
- 跟随我在oracle学习php(17)
通用设定形式 定义一个字段的时候的类型的写法. 比如: create table tab1 (f1 数据类型 ); 数据类型: 类型名[(长度n)] [unsigned] [zerofil ...
- db2常用语句
连接数据库 db2 connect to chmgmdb user ch_mgm 断开数据库 db2 disconnect current 查询 db2 "select * from btp ...
- Java基本概述
1.java语言的特点 1.面向对象:基本概念(类,对象) 三大特征:封装.继承.多态 2.健壮性 3.跨平台:通过Java语言的编写的应用程序在不同的系统平台上都能可以进行运行. 2.什么是JDK. ...
- ios打包unity应用以及配置签名
先决条件是必须为苹果mac机.拥有公司苹果账号,并确保电脑上安装了unity,unity包 ios-support.和xcode. 1.打开了unity应用之后,选择buildSettings 然后点 ...
- Shell编程实战
Shell编程实战 为什么要学习Shell编程 Shell脚本语言是实现Linux/Unix系统管理及自动化运维所必须的重要工具,Linux系统的底层以及基础应用软件的核心大都涉及Shell脚本的 ...
- tfs增加用户
1.windows上添加用户 2.tfs对应项目添加该用户 3.注意: 要设置服务器对应的本地安全策略 从网络上允许该用户访问
- struts校验
Struts2 校验框架 Struts2 和Struts1同样也提供了校验框架,但在Struts2 已经不再把校验框架做为一个插件,而是已经内置到了Struts2中,而且配置起来更为简单方便,功能也更 ...
- 自动化运维之ansible
第三十九课 自动化运维之ansible 目录 十五. ansible介绍 十六. ansible安装 十七. ansible远程执行命令 十八. ansible拷贝文件或目录 十九. ansible远 ...
- CG-ctf WP
week one 1 /x00 提示:有多种解法,你能找到几种 源码: writer up: 题目直接给出了源码,get 到一个 nctf 这个变量,int ereg(string pattern, ...