IOS UIVIEW layer动画 总结(转)
转发自:http://www.aichengxu.com/article/%CF%B5%CD%B3%D3%C5%BB%AF/16306_12.html
IOS UIVIEW layer动画 总结,有需要的朋友可以参考下。
这是我搜索的所有动画效果,感谢前辈在网上分享.
//翻页效果动画 左边
[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:YES];
[UIView commitAnimations]; //翻页效果动画 右边
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.35f];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations]; //lar动画,从上到下模糊
CATransition *animation = [CATransition animation];
[animation setDuration:2.0f];
[animation setFillMode:kCAFillModeForwards];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromBottom];
[self.navigationController.navigationBar.layer addAnimation:animation forKey:nil]; //折页效果动画
[UIView animateWithDuration:0.35f animations:^
{
/**
* @see http://donbe.blog.163.com/blog/static/138048021201061054243442/
*
* @param transform 形变属性(结构体),可以利用这个属性去对view做一些翻转或者缩放.详解请猛戳↑URL.
*
* @method valueWithCATransform3D: 此方法需要一个CATransform3D的结构体.一些非详细的讲解可以看下面的URL
*
* @see http://blog.csdn.net/liubo0_0/article/details/7452166
*
*/ self.navigationController.view.transform = CGAffineTransformMakeScale(0.001, 0.001); CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"]; // 向右旋转45°缩小到最小,然后再从小到大推出.
animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.70, 0.40, 0.80)]; /**
* 其他效果:
* 从底部向上收缩一半后弹出
* animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.0, 1.0, 0.0)];
*
* 从底部向上完全收缩后弹出
* animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 1.0, 0.0, 0.0)];
*
* 左旋转45°缩小到最小,然后再从小到大推出.
* animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.50, -0.50, 0.50)];
*
* 旋转180°缩小到最小,然后再从小到大推出.
* animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, 0.1, 0.2, 0.2)];
*/ animation.duration = 2;
animation.repeatCount = 1;
[self.navigationController.view.layer addAnimation:animation forKey:nil]; }
completion:^(BOOL finished)
{
[UIView animateWithDuration:0.35f animations:^
{
self.navigationController.view.transform = CGAffineTransformMakeScale(1.0, 1.0);
}];
}]; //从下到上模糊推出
CATransition *animation = [CATransition animation];
[animation setDuration:1.0f];
[animation setType:kCATransitionReveal];
[animation setSubtype:kCATransitionFromTop];
[animation setFillMode:kCAFillModeForwards];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]]; [self.navigationController.navigationBar.layer addAnimation:animation forKey:nil]; //旋转动画
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat:(2 * M_PI) * 2];
rotationAnimation.duration = 0.35f;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scaleAnimation.toValue = [NSNumber numberWithFloat:0.0];
scaleAnimation.duration = 0.35f;
scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.duration = 2.35f;
animationGroup.autoreverses = YES;
animationGroup.repeatCount = 1;
animationGroup.animations =[NSArray arrayWithObjects:rotationAnimation, nil];
[self.navigationController.view.layer addAnimation:animationGroup forKey:@"animationGroup"]; [UIView commitAnimations];
CATransition *animation = [CATransition animation];
[animation setDuration:0.8];
/* 各种动画效果*/
/* type类型 */ /*这里要注意不用私有方法*/
/*
pageCurl 向上翻一页
pageUnCurl 向下翻一页
rippleEffect 滴水效果
suckEffect 收缩效果,如一块布被抽走
cube 立方体效果
oglFlip 上下翻转效果
*/ [animation setType: kCATransitionReveal];
/* 动画方向*/
/* SubType类型 */
/*
kCATransitionFade淡出
kCATransitionMoveIn覆盖原图
kCATransitionPush推出
kCATransitionReveal底部显出来
也可以有四种类型:
kCATransitionFromRight;
kCATransitionFromLeft
kCATransitionFromTop;
kCATransitionFromBottom
*/
[animation setSubtype: kCATransitionFromBottom];
/* 动画的开始与结束的快慢*/
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; [self.navigationController.self.view.layer addAnimation:animation forKey:nil]; //这里应用场景是已经有2个viewController插入要的self.view上
/*
[self.view insertSubview:self.blueController.view atIndex:0];
[self.view insertSubview:self.yellowController.view atIndex:1];
*/ [self.view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
//UIView开始动画,第一个参数是动画的标识,第二个参数附加的应用程序信息用来传递给动画代理消息 [UIView beginAnimations:@"animation" context:nil];
//动画持续时间
[UIView setAnimationDuration:1.25];
//设置动画的回调函数,设置后可以使用回调方法
[UIView setAnimationDelegate:self];
//设置动画曲线,控制动画速度
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
//设置动画方式,并指出动画发生对象
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:YES];//cache
/*cache
如果是YES,那么在开始和结束图片视图渲染一次并在动画中创建帧;否则,视图将会在每一帧都渲染。例如缓存,你不需要在视图转变中不停的更新,你只需要等到转换完成再去更新视图。
讨论
*/
//设置动画重复
[UIView setAnimationRepeatCount:5.0];
//提交UIView动画 结束动画
[UIView commitAnimations]; //开始一个动画块
[UIView beginAnimations:@"animationID" context:nil];
//设置动画块中的动画持续时间(用秒)
[UIView setAnimationDuration:1.5f];
//设置动画块中的动画属性变化的曲线
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
/*变化曲线还有
( UIViewAnimationCurveEaseInOut, // slow at beginning and end
UIViewAnimationCurveEaseIn, // slow at beginning
UIViewAnimationCurveEaseOut, // slow at end
UIViewAnimationCurveLinear)
*/ //设置动画块中的动画效果是否自动重复播放。
[UIView setAnimationRepeatAutoreverses:NO]; //设置动画在动画模块中的重复次数
//setAnimationRepeatCount:
//设置动画消息的代理。
[UIView setAnimationDelegate:self]; /* UIView动画的代理方法
// [UIView
// //设置消息给动画代理当动画开始的时候
// setAnimationWillStartSelector:@selector(resizeAnimationWillStart:context:)];
// [UIView
// //设置消息给动画代理当动画停止的时候
// setAnimationDidStopSelector:@selector(resizeAnimationDidStop:finished:context:)];
//将效果作用在指定的view
*/
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:YES];
/*
效果还有(UIViewAnimationTransitionFlipFromLeft,UIViewAnimationTransitionFlipFromRight,UIViewAnimationTransitionCurlUp,UIViewAnimationTransitionCurlDown)
*/
//显示在最前面
[self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
//结束动画
[UIView commitAnimations];
IOS UIVIEW layer动画 总结(转)的更多相关文章
- ios中layer动画和UIView动画代码总结
kCATransitionFade淡出 kCATransitionMoveIn覆盖原图 kCATransitionPush推出 kCATransitionReveal底部显出来 pageC ...
- ios uiview封装动画(摘录)
iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...
- ios UIView常用动画效果
一 //调用 1 2 3 4 5 6 if(m_viewScenario.superview == nil)<br>{ m_viewScenario.alpha = 1.0; ...
- iOS开发UI篇—核心动画(UIView封装动画)
iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...
- IOS开发-UIView之动画效果的实现方法(合集)
http://www.cnblogs.com/GarveyCalvin/p/4193963.html 前言:在开发APP中,我们会经常使用到动画效果.使用动画可以让我们的APP更酷更炫,最重要的是优化 ...
- iOS学习——核心动画之Layer基础
iOS学习——核心动画之Layer基础 1.CALayer是什么? CALayer我们又称它叫做层.在每个UIView内部都有一个layer这样一个属性,UIView之所以能够显示,就是因为它里面有这 ...
- iOS开发——UI精选OC篇&UIApplication,UIWindow,UIViewController,UIView(layer)简单介绍
UIApplication,UIWindow,UIViewController,UIView(layer)简单介绍 一:UIApplication:单例(关于单例后面的文章中会详细介绍,你现在只要知道 ...
- 用layer添加UIView的动画
项目有时会遇到用UIView 添加动画的情况,这里我觉得在layer上添加动画比较好,因为可以详细地设定动画属性,方便理解 下面是一个旋转动画: -(void)roundBtnAction:(id)s ...
- iOS - UIView 动画
1.UIView 动画 核心动画 和 UIView 动画 的区别: 核心动画一切都是假象,并不会真实的改变图层的属性值,如果以后做动画的时候,不需要与用户交互,通常用核心动画(转场). UIView ...
随机推荐
- linux的cron服务及应用
Linux下的Cron用于定时执行设置的周期性指令,是Linux的内置服务,可以用以下的方法启动.关闭这个服务: /sbin/service crond start //启动服务 /sbin/serv ...
- Adobe Edge Animate –弹性的方块-使用tweenmax缓动效果
Adobe Edge Animate –弹性的方块-使用tweenmax缓动效果 版权声明: 本文版权属于 北京联友天下科技发展有限公司. 转载的时候请注明版权和原文地址. 此前有Edge爱好者提出一 ...
- 【阔别许久的博】【我要开始攻数学和几何啦】【高精度取模+同余模定理,*】POJ 2365 The Embarrassed Cryptographer
题意:给出一大数K(4 <= K <= 10^100)与一整数L(2 <= L <= 106),K为两个素数的乘积(The cryptographic keys are cre ...
- log4net在WinForm和ASP.net下的设置
下载log4net.dll,放到bin目录下,然后引用到工程.下面说明配置和调用方法. 1.AssemblyInfo.cs末尾添加 [assembly: log4net.Config.XmlConfi ...
- nmap命令-----高级用法
探测主机存活常用方式 (1)-sP :进行ping扫描 打印出对ping扫描做出响应的主机,不做进一步测试(如端口扫描或者操作系统探测): 下面去扫描10.0.3.0/24这个网段的的主机 nmap ...
- html5 之 canvas 相关知识(一)概念及定义
什么是 Canvas? HTML5 的 canvas 元素使用 JavaScript 在网页上绘制图像. 画布是一个矩形区域,您可以控制其每一像素. canvas 拥有多种绘制路径.矩形.圆形.字符以 ...
- Networking - ARP 协议
ARP 协议概述 ARP(Address Resolution Protocol),即地址解析协议,用于把 IP 地址映射到物理地址.网段上的每台主机都维护着一个被称为 ARP Table 或 ARP ...
- 【转】Github入门教程
原文 http://www.eoeandroid.com/thread-274556-1-1.html [初识Github] 首先让我们大家一起喊一句“Hello Github”.YEAH!就是这样. ...
- Linux命令(6):mv命令
1.作用: 为文件或目录改名或将文件由一个目录移入另一个目录中 2.格式: mv [选项] 源文件或目录 目标文件或目录 3.常见参数: 4.使用实例: [root@localhost ~]# mv ...
- C# to Maxscript
I figured I’d do a quick tutorial about something a little more difficult, but still very important. ...