转发自: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. 回溯(UVA129)

    POINT: 如何判断是否包含连续重复子串? 判断 当前串 的 后缀 啦~~~ You have been employed by the organisers of a Super Krypton ...

  2. Ubuntu升级显卡驱动后开机无动画的解决办法

    我的联想Ideapad z460,Nvidia GEFORCE 310M的显卡,安装闭源的驱动非常的蛋疼,ubuntu下面有附加驱动管理,在里面直接就能安装,也可以到官网下载.run的安装包,比较的折 ...

  3. 使用GBK编码请求访问nodejs程序报415错误:Error: unsupported charset at urlencodedParser ...

    最近遇到一个问题,第三方用户向我们提供给的回调地址发送请求时一直报415错误,结果发现他们使用的是GBK编码请求,而我们使用的node + express4 程序,不支持GBK编码请求. 问题出在下面 ...

  4. 转:C++ 性能测试支持

    转: http://codinginet.com/articles/view/201606-use_gtestx_for_benchmark?simple=1&from=timeline&am ...

  5. linux两种增加交换分区(swap)的方法

    在安装Oracle后,为使Oracle流畅运行,需要手动增加linux的交换分区(相当于Windows下的虚拟内存)的大小,本文介绍两种增加交换分区(swap)的方法. 第一种方法:新建分区 1.fd ...

  6. Android平台使用SQLite数据库存储数据

    创建一个DataBaseHelper的类,这个类是继承SQLiteOpenHelper类的,这个类中包含创建数据库.打开数据库.创建表.添加数据和查询数据的方法.代码如下: package com.e ...

  7. VSFTPD无法上传的解决方法

    搭建好FTP之后就没有去测试了,今天去试了一下上传的时候发生错误了,无法上传,提示“553 Could not create file”错误, 上网找了一些资料,发现很多都说是权限和防火墙的问题,但是 ...

  8. 如何查看JDK是64bit还是32bit

    在eclipse或MyEclipse中创建一个Java Project并运行如下代码: public class Test { public static void main(String[] arg ...

  9. Contoso 大学 - 9 - 实现仓储和工作单元模式

    原文 Contoso 大学 - 9 - 实现仓储和工作单元模式 By Tom Dykstra, Tom Dykstra is a Senior Programming Writer on Micros ...

  10. Js跳出循环

    break和 continue break 中断整个循环 continue 跳出当前循环,进入下一次循环 break示例: 例1: 例2: Continue:跳出当前循环,进入下一次循环 Break与 ...