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后端程序代 ...
随机推荐
- InvokeRepeating重复定时器
JS // Starting in 2 seconds.// a projectile will be launched every 0.3 secondsvar projectile : Rigid ...
- [BZOJ2124]等差子序列/[CF452F]Permutation
[BZOJ2124]等差子序列/[CF452F]Permutation 题目大意: 一个\(1\sim n\)的排列\(A_{1\sim n}\),询问是否存在\(i,j(i<j)\),使得\( ...
- Codeforces Round #396 (Div. 2) E. Mahmoud and a xor trip dfs 按位考虑
E. Mahmoud and a xor trip 题目连接: http://codeforces.com/contest/766/problem/E Description Mahmoud and ...
- Codeforces Round #370 (Div. 2) B. Memory and Trident 水题
B. Memory and Trident 题目连接: http://codeforces.com/contest/712/problem/B Description Memory is perfor ...
- 使用 IntraWeb (17) - 基本控件之 TIWRadioButton、TIWRadioGroup、TIWCheckBox
TIWRadioButton //单选 TIWRadioGroup //单选组 TIWCheckBox //复选 TIWRadioButton 所在单元及继承链: IWCompRadioButton. ...
- nginx File not found 错误(转)
当我没初始配在lnmp的时候,用浏览器打开查看php能否解析网页的时出现File not found 不用惊奇让我我们分析一下 使用php-fpm解析PHP,"No input file s ...
- HAL驱动的串口编程陷阱
http://bbs.elecfans.com/jishu_464356_1_1.html 手上有块NUCLEO STM32L053x板子,用来做串口实验,看了下ST的最新库HAL驱动,于是想用HAL ...
- ICO如此疯狂为哪般?
编者语: 独角兽一词起源于硅谷,是投资行业,尤其是风险投资业的术语,指的是那些估值超过十亿美元的创业公司.独角兽凤毛麟角,占创业公司总数的0.1%都不到.鑫根资本认为,一个独角兽能达到如此估值,肯定是 ...
- centos中安装tomcat6
在centos中安装tomcat6 1)通过yum自动安装tomcat和dependences root@Centos_AAA ~]# yum install tomcat6 [root@Cent ...
- Delphi下让窗口不显示在任务栏的另类方法
刚才看到了这篇东西<使窗口不在任务栏上显示(利用ITaskbarList接口)>,作者用ITaskList接口实现了隐藏窗口在任务栏按钮的功能,想起我好多年以前做的程序也有这样的功能,但是 ...