iPhone跳转的动画效果类型及实现方法 CATransition
实现iphone漂亮的动画效果主要有两种方法,一种是UIView层面的,一种是使用CATransition进行更低层次的控制,
第一种是UIView,UIView方式可能在低层也是使用CATransition进行了封装,它只能用于一些简单的、常用的效果展现,这里写一个常用的示例代码,供大家参考。
viewplaincopy to clipboardprint?
1.[UIView beginAnimations:@"Curl"context:nil];//动画开始
2.[UIView setAnimationDuration:0.75];
3.[UIView setAnimationDelegate:self];
4.[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:myview cache:YES];
5.[myview removeFromSuperview];
6.[UIView commitAnimations];
[UIViewbeginAnimations:@"Curl"context:nil];//动画开始[UIView setAnimationDuration:0.75];[UIView setAnimationDelegate:self];[UIViewsetAnimationTransition:UIViewAnimationTransitionCurlUp forView:myviewcache:YES];[myview removeFromSuperview];[UIView commitAnimations];
第二种方式相对复杂一些,但如果更好的进行控制,还是使用这种方法吧,基本使用方法可以看一下如下例子:
viewplaincopy to clipboardprint?
1.CATransition *animation = [CATransition animation];
2.[animation setDuration:1.25f];
3.[animation setTimingFunction:[CAMediaTimingFunction
4.functionWithName:kCAMediaTimingFunctionEaseIn]];
5.[animation setType:kCATransitionReveal];
6.[animation setSubtype: kCATransitionFromBottom];
7.[self.view.layer addAnimation:animation forKey:@"Reveal"];
CATransition*animation = [CATransition animation];[animation setDuration:1.25f];[animationsetTimingFunction:[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseIn]];[animationsetType:kCATransitionReveal];[animation setSubtype:kCATransitionFromBottom];[self.view.layer addAnimation:animationforKey:@"Reveal"];
这里使用了setType与setSubtype组合,这使用个比较保险,因为他的参数就是官方API里定义的,他们的参数说明可以参考如下:
viewplaincopy to clipboardprint?
1.setType:可以返回四种类型:
2.kCATransitionFade淡出
3.kCATransitionMoveIn覆盖原图
4.kCATransitionPush推出
5.kCATransitionReveal底部显出来
6.setSubtype:也可以有四种类型:
7.kCATransitionFromRight;
8.kCATransitionFromLeft(默认值)
9.kCATransitionFromTop;
10. kCATransitionFromBottom
setType:可以返回四种类型:kCATransitionFade淡出kCATransitionMoveIn覆盖原图kCATransitionPush推出kCATransitionReveal底部显出来setSubtype:也可以有四种类型:kCATransitionFromRight;kCATransitionFromLeft(默认值)kCATransitionFromTop;kCATransitionFromBottom
还有一种设置动画类型的方法,不用setSubtype,只用setType
viewplaincopy to clipboardprint?
1.[animation setType:@"suckEffect"];
[animationsetType:@"suckEffect"];
这里的suckEffect就是效果名称,可以用的效果主要有:
viewplaincopy to clipboardprint?
1.pageCurl 向上翻一页
2.pageUnCurl 向下翻一页
3.rippleEffect 滴水效果
4.suckEffect 收缩效果,如一块布被抽走
5.cube 立方体效果
6.oglFlip 上下翻转效果
pageCurl 向上翻一页pageUnCurl 向下翻一页rippleEffect 滴水效果suckEffect 收缩效果,如一块布被抽走cube 立方体效果oglFlip上下翻转效果
最后再给出一种常用代码供大家参考。
viewplaincopy to clipboardprint?
1.// Curl the image up or down
2.CATransition *animation = [CATransition animation];
3.[animation setDuration:0.35];
4.[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
5.if (!curled){
6.//animation.type = @"mapCurl";
7.animation.type = @"pageCurl";
8.animation.fillMode = kCAFillModeForwards;
9.animation.endProgress = 0.99;
10. } else {
11. //animation.type = @"mapUnCurl";
12. animation.type = @"pageUnCurl";
13. animation.fillMode = kCAFillModeBackwards;
14. animation.startProgress = 0.01;
15. }
16. [animation setRemovedOnCompletion:NO];
17. [view exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
18. [view addAnimation:animation forKey"pageCurlAnimation"];
19. // Disable user interaction where necessary
20. if (!curled) {
21.
22. } else {
23.
24. }
25. curled = !curled;
// Curl the image up or downCATransition *animation =[CATransition animation];[animation setDuration:0.35];[animationsetTimingFunction:UIViewAnimationCurveEaseInOut];if (!curled){//animation.type= @"mapCurl";animation.type =@"pageCurl";animation.fillMode =kCAFillModeForwards;animation.endProgress = 0.99;} else {//animation.type =@"mapUnCurl";animation.type =@"pageUnCurl";animation.fillMode = kCAFillModeBackwards;animation.startProgress= 0.01;}[animation setRemovedOnCompletion:NO];[view exchangeSubviewAtIndex:0withSubviewAtIndex:1];[view addAnimation:animationforKey"pageCurlAnimation"];// Disable user interaction wherenecessaryif (!curled) { } else { }curled = !curled;
iPhone跳转的动画效果类型及实现方法 CATransition的更多相关文章
- ios学习--详解IPhone动画效果类型及实现方法
详解IPhone动画效果类型及实现方法是本文要介绍的内容,主要介绍了iphone中动画的实现方法,不多说,我们一起来看内容. 实现iphone漂亮的动画效果主要有两种方法,一种是UIView层面的,一 ...
- iOS的动画效果类型及实现方法
实现iOS漂亮的动画效果主要有两种方法, 一种是UIView层面的, 一种是使用CATransition进行更低层次的控制, 第一种是UIView,UIView方式可能在低层也是使用CATransit ...
- CATransition的动画效果类型及实现方法--老代码备用参考
实现iphone漂亮的动画效果主要有两种方法,一种是UIView层面的,一种是使用CATransition进行更低层次的控制, 第一种是UIView,UIView方式可能在低层也是使用CATransi ...
- 《转载》两个activity界面间跳转切换动画效果
1overridePendingTransition Activity的切换动画指的是从一个activity跳转到另外一个activity时的动画. 它包括两个部分:一部分是第一个activity退出 ...
- Sencha touch Panel之间的跳转(如不使用TabPanel或者Carousel控件而产生跳转的动画效果)
常规的Sencha touch 应用都是"header content footer"结构,这样的结构无疑将使用TabPanel来实现,而且TabPanel肯定是card布局,这样 ...
- CSS3 页面跳转的动画效果
从左侧弹出: var windowWidth = window.innerWidth; $(atlas_list).css({ "transition":"none&qu ...
- jQuery 的动画效果图片----隐藏打开方法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- IOS开发-UIView之动画效果的实现方法(合集)
http://www.cnblogs.com/GarveyCalvin/p/4193963.html 前言:在开发APP中,我们会经常使用到动画效果.使用动画可以让我们的APP更酷更炫,最重要的是优化 ...
- Java 给PPT添加动画效果(预设动画/自定义动画)
PPT幻灯片中对形状可设置动画效果,常见的动画效果为内置的固定类型,即动画效果和路径是预先设定好的固定模板,但在设计动画效果时,用户也可以按照自己的喜好自定义动画动作路径.下面,通过Java后端程序代 ...
随机推荐
- MIT-6.828-JOS-lab5:File system, Spawn and Shell
Lab 5: File system, Spawn and Shell tags: mit-6.828 os 概述 本lab将实现JOS的文件系统,只要包括如下四部分: 引入一个文件系统进程(FS进程 ...
- Linux-C基础编程
GCC工作流程 工作流程 1.预处理 -E xxx.c —> xxx.i 宏替换:头文件展开:注释去掉: gcc -E hello.c -o hello.i 2.编译 -S xxx.i —> ...
- 使用Synchronized块同步变量
我们可以通过synchronized块来同步特定的静态或非静态方法.要想实现这种需求必须为这些特定的方法定义一个类变量,然后将这些方法的代码用synchronized块括起来,并将这个类变量作为参数传 ...
- CentOS7下安装MySQL5.7安装与配置(YUM)
http://blog.csdn.net/xyang81/article/details/51759200 安装环境:CentOS7 64位 MINI版,安装MySQL5.7 1.配置YUM源 在My ...
- BZOJ.1923.[SDOI2010]外星千足虫(高斯消元 异或方程组 bitset)
题目链接 m个方程,n个未知量,求解异或方程组. 复杂度比较高,需要借助bitset压位. 感觉自己以前写的(异或)高斯消元是假的..而且黄学长的写法都不需要回代. //1100kb 324ms #i ...
- BZOJ1712 : [Usaco2007 China]Summing Sums 加密
设$s[i]$为进行$i$次加密后所有奶牛数字的和,有$s[i]=(n-1)s[i-1]$. 设$c[i]$为某头固定的奶牛进行$i$次加密后的数字, 若$i$为奇数,有: \[c[i]=((1-n) ...
- 在mysql中使用group by和order by取每个分组中日期最大一行数据
转载自:https://blog.csdn.net/shiyong1949/article/details/78482737 在mysql中使用group by进行分组后取某一列的最大值,我们可以直接 ...
- centos docker compose安装
docker compose离线安装 通过联网机器下载docker-compose离线安装包(参见Downloads部分) https://github.com/docker/compose/rele ...
- 研究table-cell和overflow
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- [原创]Fitnesse测试工具介绍及安装
1 Fitnesse简介 Fitnesse是一款开源的验收测试框架,完全有java语言编写完成,支持多语言软件产品的测试,包括(java,c,c++,python,php),在Fitnesse框架中, ...