转发自: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动画 总结(转)的更多相关文章

  1. ios中layer动画和UIView动画代码总结

    kCATransitionFade淡出  kCATransitionMoveIn覆盖原图  kCATransitionPush推出  kCATransitionReveal底部显出来    pageC ...

  2. ios uiview封装动画(摘录)

    iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...

  3. ios UIView常用动画效果

    一 //调用 1 2 3 4 5 6 if(m_viewScenario.superview == nil)<br>{     m_viewScenario.alpha = 1.0;    ...

  4. iOS开发UI篇—核心动画(UIView封装动画)

    iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...

  5. IOS开发-UIView之动画效果的实现方法(合集)

    http://www.cnblogs.com/GarveyCalvin/p/4193963.html 前言:在开发APP中,我们会经常使用到动画效果.使用动画可以让我们的APP更酷更炫,最重要的是优化 ...

  6. iOS学习——核心动画之Layer基础

    iOS学习——核心动画之Layer基础 1.CALayer是什么? CALayer我们又称它叫做层.在每个UIView内部都有一个layer这样一个属性,UIView之所以能够显示,就是因为它里面有这 ...

  7. iOS开发——UI精选OC篇&UIApplication,UIWindow,UIViewController,UIView(layer)简单介绍

    UIApplication,UIWindow,UIViewController,UIView(layer)简单介绍 一:UIApplication:单例(关于单例后面的文章中会详细介绍,你现在只要知道 ...

  8. 用layer添加UIView的动画

    项目有时会遇到用UIView 添加动画的情况,这里我觉得在layer上添加动画比较好,因为可以详细地设定动画属性,方便理解 下面是一个旋转动画: -(void)roundBtnAction:(id)s ...

  9. iOS - UIView 动画

    1.UIView 动画 核心动画 和 UIView 动画 的区别: 核心动画一切都是假象,并不会真实的改变图层的属性值,如果以后做动画的时候,不需要与用户交互,通常用核心动画(转场). UIView ...

随机推荐

  1. 动一动手指,玩转 Kindle Paperwhite 2 (2015.7.13)

    Crtl+F 可搜索关键词.不(da)定(si)期(bu)更新,注明本帖链接即可转载.我可懒得写太详细,所以直接引了贴吧/论坛链接,这里衷心感谢原作. 首发贴吧,结果没几个人回复加上某度抽风难止就转移 ...

  2. AIDL实现Android IPC

    1.AIDL文本解释 在软件工程中,接口定义语言(IDL)已经成为通用术语,是用来描述软件组件接口的特定语言.在Android中,该IDL被称为Android接口定义语言(AIDL),它是纯文本文件, ...

  3. zookeeper启动报错(数据目录权限不对)

    zookeeper启动报错日志: 2016-11-16 11:19:43,880 [myid:3] - INFO [WorkerReceiver[myid=3]:FastLeaderElection@ ...

  4. mvc Web api 如何在控制器中调用

    关于如何调用 mvc Web api 的方法,网上一搜就是一大把,基本都是在前台jq中调用的,但是如何在后台调用呢? 本楼主做了一下测试,仅供参考. 先写一个简单的api,如下:[域1] namesp ...

  5. 我的EntityFramework(2):简单的数据查询

    原文:我的EntityFramework(2):简单的数据查询 在上一篇博文中,已经搭建了基本的框架,接下来就进行简单的数据查询,这里主要用了Linq 常见的数据集查询 var companyList ...

  6. C# @符号的多种使用方法

    1.限定字符串用 @ 符号加在字符串前面表示其中的转义字符“不”被处理.如果我们写一个文件的路径,例如"D:/文本文件"路径下的text.txt文件,不加@符号的话写法如下:str ...

  7. SOA 的基本概念及设计原则浅议

    SOA是英文词语"Service Oriented Architecture"的缩写,中文有多种翻译,如"面向服务的体系结构"."以服务为中心的体系结 ...

  8. (转)实战Memcached缓存系统(1)Memcached基础及示例程序

    1.Cache定义 (1)狭义概念:用于CPU的相对高速处理与主存(Main Memory)的相对低速处理的之间起到协调功能的硬件设备. (2)广义概念:用于速度相差较大的两种硬件之间,起到协调两者数 ...

  9. Guzz

    http://www.cnblogs.com/shitou/archive/2011/05/31/2064838.html

  10. 【转载】GDB反向调试(Reverse Debugging)

    记得刚开始学C语言的时候,用vc的F10来调试程序,经常就是一阵狂按,然后一不小心按过了.结果又得从头再来,那时候我就问我的老师,能不能倒退回去几步.我的老师很遗憾地和我说,不行,开弓没有回头箭.这句 ...