看到一篇文章讲ios的动画, 比较齐全,转过来, UIViewAnimation动画与CATransition类动画
来源:互联网 发布:c语言指令大全 编辑:程序博客网 时间:2024/05/16 15:58
UIViewAnimation动画与CATransition类动画
CATransition
CATransition
cameraIris
cube
fade (kCATransitionFade)
moveIn (kCATransitionMoveIn)
oglFlip
pageCurl
pageUnCurl
push (kCATransitionPush)
reveal (kCATransitionReveal)
rippleEffect
suckEffect
subtype and filter
Many 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;...
push
revealfromLeft, fromRight, fromBottom, fromTop-pageCurl, pageUnCurlfromLeft, fromRight, fromTop,
alignedCubefromLeft, fromRight, fromTop, fromBottomfloat inputAmount;
alignedFlip
oglFlipfromLeft, fromRight, fromTop, fromBottomfloat inputAmount;cameraIris-CGPoint inputPosition;rippleEffect--rotate90cw, 90ccw, 180cw, 180ccw-suckEffect-CGPoint inputPosition;
Availability
The following shows the availability of different CATransitions starting from 2.0
moveIn
push
reveal(Public API) 2.0–flip
alignedFlip
oglFlip2.0–cube
alignedCube2.0–pageCurl
pageUnCurl2.0–rippleEffect2.0–suckEffect2.0–cameraIris
cameraIrisHollowOpen
cameraIrisHollowClose2.0–rotate4.0–spewEffect
genieEffect
unGenieEffect
twist
swirl
charminUltra
reflection
zoomyIn
zoomyOut
mapCurl
mapUnCurl
oglApplicationSuspend
cameraIrisHollow2.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类函数实现:
//UIViewAnimationTransitio
//UIViewAnimationTransitio
//UIViewAnimationTransitio
[UIView
[UIView
[UIView
[UIView
//在这里写你的代码.
[UIView
2.使用CATransition对象来实现:
CATransition比较强大,一般可以使用CATransition模拟UIView的动画。
CATransition
animation.delegate
animation.duration
animation.timingFunction
animation.fillMode
animation.type
animation.subtype
animation.startProgress
animation.endProgress
animation.removedOnCompletion
[self.view.layer
转自: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:UIViewAnimationTransitio
[myview removeFromSuperview];
[UIView commitAnimations];
第二种方式相对复杂一些,但如果更好的进行控制,还是使用这种方法吧,
基本使用方法可以看一下如下例子:
Cpp代码
CATransition *animation = [CATransition animation];
[animation setDuration:1.25f];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEa
[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类动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- UIViewAnimation动画与Core Animation的CATransition类动画
- 关于SQLserver2000移植到oracle9i的实践(原)
- Java中多个线程按顺序执行
- 使用 /sys 文件系统访问 Linux 内核
- 修改一个oracle序列的当前值
- QQweb登录通讯协议
- 看到一篇文章讲ios的动画, 比较齐全,转过来, UIViewAnimation动画与CATransition类动画
- HEVC学习(三十四) —— 去方块滤波之五
- 云山迅捷CMS-适用于.net二次开发的CMS
- Sqlserver 索引和数据优化(附:翻页代码)
- sequence与会话有关--oracle一个比较烂的特性
- WINCE下配置GPRS的详细过程----带图显示过程
- 修改git commit 除了 git commit --amend 还有 git commmit rebase, reset,
- 关于移动表空间中的数据文件
- 如何压缩表空间、把表移到另一个表空间