看到一篇文章讲ios的动画, 比较齐全,转过来, UIViewAnimation动画与CATransition类动画
2014-11-03 16:00
519 查看
UIViewAnimation动画与CATransition类动画
CATransition
CATransition is an Objective-C wrapper for creating view transitions. As of 3.1.2, there are 11 types of transitions. 4 of them are SDK-compatible, but are the most boring ones. The following shows all 11 types of transition from picture "A" to "B" at 40%. The subtypes, if any, is "fromLeft".cameraIris | cube | fade (kCATransitionFade) | moveIn (kCATransitionMoveIn) |
oglFlip | pageCurl | pageUnCurl | push (kCATransitionPush) |
reveal (kCATransitionReveal) | rippleEffect | suckEffect |
subtype and filter
Main article: CAFilterMany transitions have are further divided into several discrete subtypes. They often control the movement direction of the animation.Some transitions accept addition arguments through the filter property, for example, you can set the location of suckEffect using
...CAFilter* filter = [CAFilter filterWithName:@"suckEffect"];[filter setValue:[NSValue valueWithCGPoint:CGPointMake(160, 240)] forKey:@"inputPosition"];transition.filter = filter;...
Transition | Subtypes | Accepted parameters |
---|---|---|
moveIn push reveal | fromLeft, fromRight, fromBottom, fromTop | - |
pageCurl, pageUnCurl | fromLeft, fromRight, fromTop, fromBottom | float inputColor[]; |
cube alignedCube | fromLeft, fromRight, fromTop, fromBottom | float inputAmount; (perspective) |
flip alignedFlip oglFlip | fromLeft, fromRight, fromTop, fromBottom | float inputAmount; |
cameraIris | - | CGPoint inputPosition; |
rippleEffect | - | - |
rotate | 90cw, 90ccw, 180cw, 180ccw | - |
suckEffect | - | CGPoint inputPosition; |
Availability
The following shows the availability of different CATransitions starting from 2.0CATransition | Availability |
---|---|
fade moveIn push reveal | (Public API) 2.0– |
flip alignedFlip oglFlip | 2.0– |
cube alignedCube | 2.0– |
pageCurl pageUnCurl | 2.0– |
rippleEffect | 2.0– |
suckEffect | 2.0– |
cameraIris cameraIrisHollowOpen cameraIrisHollowClose | 2.0– |
rotate | 4.0– |
spewEffect genieEffect unGenieEffect twist swirl charminUltra reflection zoomyIn zoomyOut mapCurl mapUnCurl oglApplicationSuspend cameraIrisHollow | 2.0–2.2 |
References
Official reference:CATransition
Header:
http://github.com/kennytm/iphone-private-frameworks/blob/master/QuartzCore/CATransition2.h
UIViewAnimation动画与Core Animation的CATransition类动画
1.使用UIView类函数实现://UIViewAnimationTransitionFlipFromLeft, 向左转动//UIViewAnimationTransitionFlipFromRight, 向右转动
//UIViewAnimationTransitionCurlUp, 向上翻动
//UIViewAnimationTransitionCurlDown, 向下翻动
[UIView beginAnimations:@"animationID" context:nil];
[UIView setAnimationDuration:0.5f]; //动画时长
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES]; //给视图添加过渡效果
//在这里写你的代码.
[UIView commitAnimations]; //提交动画 2.使用CATransition对象来实现:CATransition比较强大,一般可以使用CATransition模拟UIView的动画。
CATransition *animation = [CATransition animation];
animation.delegate = self;
animation.duration = 0.5f; //动画时长
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = kCAFillModeForwards;
animation.type = @”cube”; //过度效果
animation.subtype = @”formLeft”; //过渡方向
animation.startProgress = 0.0 //动画开始起点(在整体动画的百分比)
animation.endProgress = 1.0; //动画停止终点(在整体动画的百分比)
animation.removedOnCompletion = NO;
[self.view.layer addAnimation:animation forKey:@"animation"];
转自:http://www.cnblogs.com/project/archive/2011/09/27/2193556.html 实现iPhone漂亮的动画效果主要有两种方法:
一种是UIView层面的,
一种是使用CATransition进行更低层次的控制,
第一种是UIView,UIView方式可能在低层也是使用CATransition进行了封装,它只能用于一些简单的、常用的效果展现,这里写一个常用的示例代码,供大家参考。
Cpp代码
[UIView beginAnimations:@"Curl"context:nil];//动画开始
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:myview cache:YES];
[myview removeFromSuperview];
[UIView commitAnimations];
第二种方式相对复杂一些,但如果更好的进行控制,还是使用这种方法吧,
基本使用方法可以看一下如下例子:
Cpp代码
CATransition *animation = [CATransition animation];
[animation setDuration:1.25f];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[animation setType:kCATransitionReveal];
[animation setSubtype: kCATransitionFromBottom];
[self.view.layer addAnimation:animation forKey:@"Reveal"];
这里使用了setType与setSubtype组合,这使用个比较保险,因为他的参数就是官方API里定义的,他们的参数说明可以参考如下:
[animation setType:@"suckEffect"];
这里的suckEffect就是效果名称,可以用的效果主要有:
Cpp代码
pageCurl 向上翻一页
pageUnCurl 向下翻一页
rippleEffect 滴水效果
suckEffect 收缩效果,如一块布被抽走
cube 立方体效果
oglFlip 上下翻转效果
iphone中CABasicAnimation和UIView动画的区别[转]
关于UIView动画:[UIView beginAnimations:@"zoom out"context:nil];
[UIView setAnimationDuration:1.f];
[UIView setAnimationCurve:UIViewAnimationCurveEase
Out];
cover.transform
=
CGAffineTransformMakeSca
le(9.25,7.05);
cover.center
=
CGPointMake(430,
512);
[UIView
commitAnimations]
UIView动画是应用在一个view上面的。关于CABasicAnimation动画:-
(CAAnimation
*)animationMove:(CGPoint)rootCenter
{
CABasicAnimation
*animationMove
=
[CABasicAnimation animationWithKeyPath:@"position"];
animationMove.duration
=
1;
animationMove.autoreverses
=
NO;
// animationMove.delegate = self;
animationMove.removedOnCompletion
=
NO;
animationMove.fillMode
=
kCAFillModeForwards;
animationMove.fromValue
=
[NSValue valueWithCGPoint:self.oldCoverCenter];
animationMove.toValue
=[NSValue valueWithCGPoint:rootCenter];
return
animationMove;
}
CABasicAnimation动画是应用在一个layer上面的。注:
1,把一个image放在一个view的layer上来放大的时候,如果用UIView来做,图片不会太多的失真和闪烁的效果,但是用CABasicAnimation来做失真和闪烁现象会很严重,效果很不好。
2,做 动画的叠加效果 很简单,只要把各自的动画放在一起就可以了。请看这个效果:一本书边移动到屏幕中间,边放大,边打开封面的效果。[imageLayer addAnimation:[self animationOpen]
forKey:@"Open"];
[UIView beginAnimations:@"zoom out"
context:nil];
[UIView setAnimationDuration:1.f];
[UIView setAnimationCurve:UIViewAnimationCurveEase
Out];
cover.transform
=
CGAffineTransformMakeSca
le(5.5,5.5);
cover.center
=
CGPointMake(629,
384);
[UIView commitAnimations];
-
(CAAnimation
*)animationOpen
{
CABasicAnimation
*animationOpen
=
[CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
animationOpen.duration
=
1;
animationOpen.autoreverses
=
NO;
animationOpen.delegate
=
self;
//然后执行真正地打开书的内容
animationOpen.removedOnCompletion
=
NO;
animationOpen.fillMode
=
kCAFillModeForwards;
animationOpen.fromValue
=
[NSNumber numberWithFloat:-M_PI/5];
animationOpen.toValue
=
[NSNumber numberWithFloat:-M_PI/1.5];
return
animationOpen;
}
相关文章推荐
- 看到一篇文章讲ios的动画, 比较齐全,转过来, UIViewAnimation动画与CATransition类动画
- 看到一篇文章讲ios的动画, 比较齐全,转过来, UIViewAnimation动画与CATransition类动画
- 看到一篇好文章,特意转过来:嵌入式软件测试的十大秘诀
- ARM的存储器映射与存储器重映射【转载】2009-12-14 10:29最近在用LPC2148,看到了一篇文章,感觉很有帮助,就转了过来。
- 刚才看到一篇文章,感觉不错,转载过来和大家分享:
- 看到一篇关于搜索引擎查询机制的文章,比较感兴趣,收藏……
- 对于SQL的Join,在学习起来可能是比较乱的。我们知道,SQL的Join语法有很多inner的,有outer的,有left的,有时候,对于Select出来的结果集是什么样子有点不是很清楚。Coding Horror上有一篇文章,通过文氏图 Venn diagrams 解释了SQL的Join。我觉得清楚易懂,转过来。 交差集" cross join 《Linux命令行与shell脚本编程大全
- CSDN上看到的一篇有关Spring JDBC事务管理的文章(内容比较全)
- 看到一篇关于上传文章,先抄过来,慢慢学习
- 【原创+转载】看到比较搞的一篇文章《重构代码的7个阶段》
- 无意中看到一篇讲洋酒的文章,感觉很长见识,转过来,分享一下
- 【敏捷】【转发】看到比较搞的一篇文章《重构代码的7个阶段》
- 看到一篇很有感触的文章,转载过来,希望更多的技术开发人员能有所得 ----五年软件开发的一点自我总结
- 看到一篇很有感触的文章,转载过来,希望更多的技术开发人员能有所得 ----五年软件开发的一点自我总结
- 刚在一个论坛看到一篇文章,说的似乎很是高深,我也不太懂,于是转载了过来,大家一起看看
- CSDN上看到的一篇有关Spring JDBC事务管理的文章(内容比较全)
- 看到的一篇比较犀利的文章-对手机终端的见解
- 看到一篇不错的Nhibernate文章转过来备忘
- CSDN上看到的一篇有关Spring JDBC事务管理的文章(内容比较全)
- 学习javascript时从网上看到的一篇比较简单和基础的文章,特转载!