CATransition类动画
- - (void)leftClick {
- [UIView beginAnimations:nil context:nil];
- //display mode, slow at beginning and end
- [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
- //动画时间
- [UIView setAnimationDuration:1.0f];
- //使用当前正在运行的状态开始下一段动画
- [UIView setAnimationBeginsFromCurrentState:YES];
- //给视图添加过渡效果
- [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:imageView cache:YES];
- [UIView commitAnimations];
- }
- - (void)rightClick {
- [UIView beginAnimations:nil context:nil];
- //display mode, slow at beginning and end
- [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
- //动画时间
- [UIView setAnimationDuration:1.0f];
- //使用当前正在运行的状态开始下一段动画
- [UIView setAnimationBeginsFromCurrentState:YES];
- //给视图添加过渡效果
- [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:imageView cache:YES];
- [UIView commitAnimations];
- }
- - (void)upClick {
- [UIView beginAnimations:nil context:nil];
- //display mode, slow at beginning and end
- [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
- //动画时间
- [UIView setAnimationDuration:1.0f];
- //使用当前正在运行的状态开始下一段动画
- [UIView setAnimationBeginsFromCurrentState:YES];
- //给视图添加过渡效果
- [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:imageView cache:YES];
- [UIView commitAnimations];
- }
- - (void)downClick {
- [UIView beginAnimations:nil context:nil];
- //display mode, slow at beginning and end
- [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
- //动画时间
- [UIView setAnimationDuration:1.0f];
- //使用当前正在运行的状态开始下一段动画
- [UIView setAnimationBeginsFromCurrentState:YES];
- //给视图添加过渡效果
- [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:imageView cache:YES];
- [UIView commitAnimations];
- }
- /*
- CATransition的type属性
- 1.#define定义的常量
- kCATransitionFade 交叉淡化过渡
- kCATransitionMoveIn 新视图移到旧视图上面
- kCATransitionPush 新视图把旧视图推出去
- kCATransitionReveal 将旧视图移开,显示下面的新视图
- 2.用字符串表示
- pageCurl 向上翻一页
- pageUnCurl 向下翻一页
- rippleEffect 滴水效果
- suckEffect 收缩效果,如一块布被抽走
- cube 立方体效果
- oglFlip 上下翻转效果
- */
- - (void)MyCAnimation1 {
- CATransition *animation = [CATransition animation];
- //动画时间
- animation.duration = 1.0f;
- //display mode, slow at beginning and end
- animation.timingFunction = UIViewAnimationCurveEaseInOut;
- //过渡效果
- animation.type = kCATransitionMoveIn;
- //过渡方向
- animation.subtype = kCATransitionFromTop;
- //添加动画
- [imageView.layer addAnimation:animation forKey:nil];
- }
- - (void)MyCAnimation2 {
- CATransition *animation = [CATransition animation];
- //动画时间
- animation.duration = 1.0f;
- //display mode, slow at beginning and end
- animation.timingFunction = UIViewAnimationCurveEaseInOut;
- //在动画执行完时是否被移除
- animation.removedOnCompletion = NO;
- //过渡效果
- animation.type = @"pageCurl";
- //过渡方向
- animation.subtype = kCATransitionFromRight;
- //暂时不知,感觉与Progress一起用的,如果不加,Progress好像没有效果
- animation.fillMode = kCAFillModeForwards;
- //动画停止(在整体动画的百分比).
- animation.endProgress = 0.7;
- [imageView.layer addAnimation:animation forKey:nil];
- }
- - (void)MyCAnimation3 {
- CATransition *animation = [CATransition animation];
- //动画时间
- animation.duration = 1.0f;
- //display mode, slow at beginning and end
- animation.timingFunction = UIViewAnimationCurveEaseInOut;
- //过渡效果
- animation.type = @"pageUnCurl";
- //过渡方向
- animation.subtype = kCATransitionFromRight;
- //暂时不知,感觉与Progress一起用的,如果不加,Progress好像没有效果
- animation.fillMode = kCAFillModeBackwards;
- //动画开始(在整体动画的百分比).
- animation.startProgress = 0.3;
- [imageView.layer addAnimation:animation forKey:nil];
- }
- - (void)MyCAnimation4 {
- [NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(updateButterfly) userInfo:nil repeats:YES];
- }
- - (void)updateButterfly {
- butterflyView.animationDuration = 0.75f;
- [self.view addSubview:butterflyView];
- [butterflyView startAnimating];
- butterflyView.center = [butterflyView randomCenterInView:self.view withInset:10.0f];
- }
CATransition比较强大,一般可以使用CATransition模拟UIView的动画。
/* 过渡效果
fade //交叉淡化过渡(不支持过渡方向)
push //新视图把旧视图推出去
moveIn //新视图移到旧视图上面
reveal //将旧视图移开,显示下面的新视图
cube //立方体翻滚效果
oglFlip //上下左右翻转效果
suckEffect //收缩效果,如一块布被抽走(不支持过渡方向)
rippleEffect //滴水效果(不支持过渡方向)
pageCurl //向上翻页效果
pageUnCurl //向下翻页效果
cameraIrisHollowOpen //相机镜头打开效果(不支持过渡方向)
cameraIrisHollowClose //相机镜头关上效果(不支持过渡方向)
*/
/*
过渡方向
fromRight;
fromLeft;
fromTop;
fromBottom;
*/
CATransition *animation = [CATransition animation];
animation.
delegate = self;
animation.duration =
0.5f;
//
动画时长
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.type =
@"
cube
";
//
过度效果
animation.subtype =
@"
formLeft
";
//
过渡方向
animation.startProgress =
0.0
//
动画开始起点(在整体动画的百分比)
animation.endProgress =
1.0;
//
动画停止终点(在整体动画的百分比)
animation.removedOnCompletion = NO;
[self.view.layer addAnimation:animation forKey:
@"
animation
"];
CATransition类动画的更多相关文章
- iOS开发CAAnimation类动画, CATransition动画
#pragma mark - CAAnimation类.实现动画 #pragma mark ** CABasicAnimation 动画 - (IBAction)handleCABasicAnimat ...
- Keyframe类-动画中关键帧概念
package com.loaderman.customviewdemo; import android.animation.Animator; import android.animation.Ke ...
- CATransition的动画效果类型及实现方法--老代码备用参考
实现iphone漂亮的动画效果主要有两种方法,一种是UIView层面的,一种是使用CATransition进行更低层次的控制, 第一种是UIView,UIView方式可能在低层也是使用CATransi ...
- CoreAnimation笔记
核心动画继承结构 CoreAnimation Core Animation是直接作用在CALayer上的(并非UIView上)非常强大的跨Mac OS X和iOS平台的动画处理API,Core Ani ...
- 动画浅析-CAAnimation和CATransition
出处: http://blog.csdn.net/mad2man/article/details/17260887 //动画播放完之后不恢复初始状态 baseAnimation.removed ...
- CATransition转场动画
背景: 最近在温习动画,分享个简单系统的转场动画 viewcontroller *VC=[self.storyboard instantiateViewControllerWithIdentifier ...
- core Animation之CATransition(转场动画)
用于做转场动画,能够为层提供移出屏幕和移入屏幕的动画效果.iOS比Mac OS X的转场动画效果少一点 UINavigationController就是通过CATransition实现了将控制器的视图 ...
- jQuery - 02. 样式表属性操作/类操作、动画、显示隐藏、滑入、淡入、停止动画、节点操作、添加对象、清空节点
样式表属性操作.css $("div").css({'width':100,'height':100,'background':'red'}); $("div" ...
- iOS开发之各种动画各种页面切面效果
因工作原因,有段时间没发表博客了,今天就发表篇博客给大家带来一些干货,切勿错过哦.今天所介绍的主题是关于动画的,在之前的博客中也有用到动画的地方,今天就好好的总结一下iOS开发中常用的动画.说道动画其 ...
随机推荐
- IS--A与 Has-a 区别
- 《转》读discuzx3.1 数据库层笔记
最近开始在看discuzx3.1的代码,看到数据库层的实现,discuzx的数据库层能够支撑数据库分库,分布式部署,主要水平分表,也可以很方便的支持其他数据库.性能上,可以做读写分离,支持数据缓存.可 ...
- struts2笔记03-ActionContext
1.概念 ActionContext是action的上下文,它包括action执行所需要的对象.struts2对每一个action都会创建一个新的ActionContext实例,同Action一样,是 ...
- U盘常见故障及检修
一般U盘故障分为软故障和硬故障,其中以软故障最为常见. 软故障主要是指U盘有坏块,从而导致U盘能被计算机识别,但没有盘符出现,或者有盘符出现,但当打开U盘时却提示要进行格式化,而格式化又不能成功.前 ...
- 读配置文件 properties
/** * */package com.sprucetec.tms.fee.utils;import java.io.IOException;import java.util.ArrayList;im ...
- perl 分析binlog 定位错误sql 思路
1. 获取需要的binlog 日志: [root@zjzc01 binlog]# mysqlbinlog --start-datetime='2016-08-01 00:00:00' --stop-d ...
- css学习笔记三
总结一下水平居中和垂直居中的方法,欢迎交流指正,共同进步! 1.水平居中 1.1):行内元素水平居中,在其父类设置text-align:center; 1.2): 块级元素水平居中有三种 第一种:定宽 ...
- 【Deep Learning】genCNN: A Convolutional Architecture for Word Sequence Prediction
作者:Mingxuan Wang.李航,刘群 单位:华为.中科院 时间:2015 发表于:acl 2015 文章下载:http://pan.baidu.com/s/1bnBBVuJ 主要内容: 用de ...
- CXF 的IP拦截
非常久没有写技术文档了,今天 记录下Webserver的Ip限制吧 需求是:webserver接口能在内网訪问,可是測试平台的webserver要能够在外网訪问,这样就有了一点差别, 这个实现的比較简 ...
- 【百度地图API】获取行政区域的边界
);map.addControl(new BMap.NavigationControl({type: BMAP_NAVIGATION_CONTROL_SMALL}));map.enableScroll ...