设为首页 加入收藏

TOP

CABasicAnimation学习Demo 包括了一些常用的动画效果(三)
2015-07-24 05:57:55 来源: 作者: 【 】 浏览:16
Tags:CABasicAnimation 学习 Demo 包括 一些 常用 动画 效果
CGContextAddQuadCurveToPoint(context, 10, 450, 310, 450); //CGContextAddQuadCurveToPoint(context, 310, 10, 10, 10); //划线 CGContextDrawPath(context, kCGPathStroke); //得到一个image 从目前的矢量上下文 UIImage *curve = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageView *curveView = [[UIImageView alloc]initWithImage:curve]; curveView.frame = CGRectMake(1, 1, 320, 460); [curveView setBackgroundColor:[UIColor clearColor]]; [self.view addSubview:curveView]; } -(void)animateCicleAlongPath { //准备关键帧动画 CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; pathAnimation.calculationMode = kCAAnimationPaced; pathAnimation.fillMode = kCAFillModeForwards; pathAnimation.removedOnCompletion = NO; pathAnimation.duration = 5.0f; pathAnimation.repeatCount = 200; //pathAnimation.autoreverses = YES; //原路返回,而不是从头再来 //设置动画路径 //CGPoint endPoint = CGPointMake(310, 450); CGMutablePathRef curvedPath = CGPathCreateMutable(); CGPathMoveToPoint(curvedPath, NULL, 10, 10); CGPathAddQuadCurveToPoint(curvedPath, NULL, 10, 450, 310, 450); CGPathAddQuadCurveToPoint(curvedPath, NULL, 310, 10, 10, 10); //已经有了路径,我们要告诉动画 路径 pathAnimation.path = curvedPath; CGPathRelease(curvedPath); //这里要手工释放 [self.ViewTest.layer addAnimation:pathAnimation forKey:nil]; } /**************************************************************************/ - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end

最后附上Demo下载地址:http://download.csdn.net/detail/u012951123/7500419

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C++11 新特性之 变长参数模板 下一篇ajax――XMLHttpRequest

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: