收藏 分享(赏)

iphone开发各种动画笔记.doc

上传人:初中学霸 文档编号:21759165 上传时间:2024-04-22 格式:DOC 页数:5 大小:19.97KB
下载 相关 举报
iphone开发各种动画笔记.doc_第1页
第1页 / 共5页
iphone开发各种动画笔记.doc_第2页
第2页 / 共5页
iphone开发各种动画笔记.doc_第3页
第3页 / 共5页
iphone开发各种动画笔记.doc_第4页
第4页 / 共5页
iphone开发各种动画笔记.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

1、iphone开发 各种动画iphone中存在很多好看的动画效果,用于页面的切换等。其中某些是apple私有的,据说私有的无法通过apple的审批。1、UIView 动画官方API中,使用UIView可以设置5个动画效果,分别为:UIViewAnimationTransitionNone 不使用动画UIViewAnimationTransitionFlipFromLeft 从左向右旋转翻页UIViewAnimationTransitionFlipFromRight 从右向左旋转翻页,与UIViewAnimationTransitionFlipFromLeft相反UIViewAnimationTr

2、ansitionCurlUp 卷曲翻页,从下往上UIViewAnimationTransitionCurlDown 卷曲翻页,从上往下详细请参见UIViewAnimationTransition例子:UIView beginAnimations:animationID context:nil;/开始一个动画块,第一个参数为动画块标识UIView setAnimationDuration:0.5f;/设置动画的持续时间UIView setAnimationCurve:UIViewAnimationCurveEaseInOut;/设置动画块中的动画属性变化的曲线,此方法必须在beginAnimat

3、ions方法和commitAnimations,默认即为UIViewAnimationCurveEaseInOut效果。详细请参见UIViewAnimationCurveUIView setAnimationRepeatAutoreverses:NO;/设置是否自动反转当前的动画效果UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES;/设置过渡的动画效果,此处第一个参数可使用上面5种动画效果self.view exchangeSubviewAtIndex:

4、1 withSubviewAtIndex:0;/页面翻转UIView commitAnimations;/提交动画2、公共动画效果使用CATransiton可以设置4种动画效果,分别为:NSString * const kCATransitionFade;/渐渐消失NSString * const kCATransitionMoveIn;/覆盖进入NSString * const kCATransitionPush;/推出NSString * const kCATransitionReveal;/与MoveIn相反例子:CATransition *animation = CATransitio

5、n animation;animation.duration = 0.5f;animation.timingFunction = UIViewAnimationCurveEaseInOut;animation.type = kCATransitionPush;/设置上面4种动画效果animation.subtype = kCATransitionFromTop;/设置动画的方向,有四种,分别为kCATransitionFromRight、kCATransitionFromLeft、kCATransitionFromTop、kCATransitionFromBottomself.view.lay

6、er addAnimation:animation forKey:animationID;3、私有动画iphone种还有很多动画是苹果私有的,例如删除照片的动画等,私有动画可以直接在animation.type中传入动画的字符串即可。动画有以下几种:cube:像立方体一样翻转suckEffect:渐渐缩小,与删除照片动画一样oglFlip:上下旋转,当subType为fromLeft或者fromRight时,与UIViewAnimationTransitionFlipFromLeft和UIViewAnimationTransitionFlipFromRight一样rippleEffect:水波

7、效果pageCurl:与UIViewAnimationTransitionCurlUp一样pageUnCurl:与UIViewAnimationTransitionCurlDown一样cameraIrisHollowOpen:First half of cameraIris.cameraIrisHollowClose:Second half of cameraIris以上所有动画效果的demo请见同时,本人在使用UIView实现suckEffect缩小的效果过程中遇到一个问题(不知道如何定位),经过搜索终觅得解决方法,分享如下:UIView beginAnimations:suck conte

8、xt:NULL;UIView setAnimationTransition:103 forView:self.view cache:YES;UIView setAnimationDuration:0.5f;if (self.interfaceOrientation = UIInterfaceOrientationPortrait | self.interfaceOrientation =UIInterfaceOrientationPortraitUpsideDown) UIView setAnimationPosition:CGPointMake(44, 42);else UIView set

9、AnimationPosition:CGPointMake(320 , 42);UIView commitAnimations;其中setAnimationPosition方法就是用于设置缩小点的位置的,此处虽然会报一个警告,但是结果还是正确的除了如上所述的动画方法外也可以用CABasicAnimation来设置动画:使用CABasicAnimation类实现的基础动画,是通过2个值,一个开始的,一个结束的来做动画的。例如,为了在窗口中,移动从一个点到另一个点,我们能够使用关键路径position创建一个基础动画。我们可以给动画一个开始的值和一个结束的值,然后增加动画到层中。在下一个运行循环中

10、,那个动画就可以立即执行/其中soccer是UIImageView类型的成员。/让足球来回移动 CABasicAnimation *translation = CABasicAnimation animationWithKeyPath:position; translation.fromValue = NSValue valueWithCGPoint:CGPointMake(24, 240); translation.toValue = NSValue valueWithCGPoint:CGPointMake(320- 24, 240); translation.duration = 2; /

11、动画持续时间 translation.repeatCount = HUGE_VALF; /动画重续次数 translation.autoreverses = YES; /是否自动重复 /让足球来回转动 CABasicAnimation*rotation=CABasicAnimationanimationWithKeyPath:transform.rotation.z; /kCAMediaTimingFunctionLinear 表示时间方法为线性,使得足球匀速转动 rotation.timingFunction=CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionLinear; rotation.toValue = NSNumber numberWithFloat:4 * M_PI; rotation.duration = 2; rotation.repeatCount = HUGE_VALF; rotation.autoreverses = YES; soccer.layer addAnimation:rotation forKey:rotation;soccer.layer addAnimation:translation forKey:translation;详细实例请看附带的demo。

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高中资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:文库网官方知乎号:文库网

经营许可证编号: 粤ICP备2021046453号世界地图

文库网官网©版权所有2025营业执照举报