CAKeyFrameAnimation 的简单用法
来源:互联网 发布:奶茶网络营销策划方案 编辑:程序博客网 时间:2024/05/18 21:10
CAKeyFrameAnimation: 我们可以用 CGPath 来执行动画的轨迹
- (void)positionLayer { //创建路径 UIGraphicsBeginImageContext(self.view.bounds.size); CGContextRef contextRef = UIGraphicsGetCurrentContext(); CGMutablePathRef path = CGPathCreateMutable(); CGAffineTransform transform = CGAffineTransformIdentity; CGPathMoveToPoint(path, &transform, 200, 199); CGPathAddArc(path, &transform, 150, 199, 50, 0, M_PI*2, NO); CGContextAddPath(contextRef, path); [[UIColor redColor]setStroke]; CGContextSetLineWidth(contextRef, 3); CGContextDrawPath(contextRef, kCGPathStroke); UIImage * image = UIGraphicsGetImageFromCurrentImageContext(); UIImageView * imageView = [[UIImageView alloc]initWithImage:image]; [self.view addSubview:imageView]; UIGraphicsEndImageContext(); //初始化positionLayer CALayer * positionLayer = [[CALayer alloc]init]; positionLayer.backgroundColor = [UIColor blueColor].CGColor; positionLayer.frame = CGRectMake(0, 100, 10, 10); positionLayer.cornerRadius = 3; [self.view.layer addSublayer:positionLayer]; CAKeyframeAnimation * keyFrameAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; keyFrameAnimation.removedOnCompletion = NO; keyFrameAnimation.fillMode = kCAFillModeForwards; keyFrameAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; keyFrameAnimation.autoreverses = NO; keyFrameAnimation.duration = 2; keyFrameAnimation.repeatCount = MAXFLOAT; keyFrameAnimation.path = path; [positionLayer addAnimation:keyFrameAnimation forKey:nil]; CGPathRelease(path);}
0 0
- CAKeyFrameAnimation 的简单用法
- CAKeyframeAnimation的简单使用
- CAKeyframeAnimation的简单使用
- CAKeyframeAnimation 关键帧动画的用法
- CABasicAnimation, CAKeyframeAnimation,CAAnimationGroup动画的用法
- CAKeyframeAnimation(关键帧动画)的简单使用
- CABaseAnimation + CAAnimationGroup + CAKeyframeAnimation的简单动画
- CAKeyframeAnimation简单旋转动画
- CAKeyframeAnimation动画的使用
- CAKeyframeAnimation
- CAKeyframeAnimation
- CAKeyframeAnimation
- CAKeyframeAnimation
- CAKeyFrameAnimation
- CAKeyframeAnimation
- CAKeyframeAnimation
- CAKeyframeAnimation + RMMap 闪退的问题
- CAKeyframeAnimation keyPath可以是用的key
- “微信应用号对行业影响”之一,app开发速来围观
- 三维重建:SLAM的粒度和工程化问题
- mysql关键字,建表时必须注意
- C++类成员指针的意义
- Swift OC混编
- CAKeyFrameAnimation 的简单用法
- Android Service完全解析,关于服务你所需知道的一切(上)
- JSON格式化输出
- [C# 线程处理系列]专题一:线程基础
- html5 面试题目汇总
- 索引的升序 降序
- Creo/Proe 二次开发中使用 QT 编程流程
- 如何保证android手机中我们的应用字号不受系统设置的字号影响
- 从零开始搭建架构实施Android项目