//    方法一 用法1​ Value方式
//创建动画对象 CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"]; //设置value NSValue *value1=[NSValue valueWithCGPoint:CGPointMake(100, 100)]; NSValue *value2=[NSValue valueWithCGPoint:CGPointMake(200, 100)]; NSValue *value3=[NSValue valueWithCGPoint:CGPointMake(100, 200)]; NSValue *value4=[NSValue valueWithCGPoint:CGPointMake(200, 200)]; NSValue *value5=[NSValue valueWithCGPoint:CGPointMake(100, 300)]; NSValue *value6=[NSValue valueWithCGPoint:CGPointMake(200, 300)]; animation.values=@[value1,value2,value3,value4,value5,value6]; //重复次数 默认为1 // animation.repeatCount=MAXFLOAT; //设置是否原路返回默认为不 // animation.autoreverses = YES; //设置移动速度,越小越快 animation.duration = 4.0f; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards; animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; animation.delegate=self; //给这个view加上动画效果 [redView.layer addAnimation:animation forKey:nil];

CAKeyframeAnimation *keyframeAnimation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
// 创建一个CGPathRef对象,就是动画的路线
CGMutablePathRef path = CGPathCreateMutable();
// 设置开始位置
CGPathMoveToPoint(path, NULL, redView.layer.position.x-40, redView.layer.position.y+40);//移动到起始点
// 沿着路径添加四曲线点移动
CGPathAddQuadCurveToPoint(path, NULL, 100, 100, self.view.frame.size.width, 0);
keyframeAnimation.path = path;
keyframeAnimation.delegate = self;
CGPathRelease(path);
keyframeAnimation.duration = 7;
[redView.layer addAnimation:keyframeAnimation forKey:@"KCKeyframeAnimation_Position"];

OC动画:CAKeyframeAnimation的更多相关文章

  1. iOS:核心动画之关键帧动画CAKeyframeAnimation

    CAKeyframeAnimation——关键帧动画 关键帧动画,也是CAPropertyAnimation的子类,与CABasicAnimation的区别是: –CABasicAnimation只能 ...

  2. OC - 25.CAKeyframeAnimation

    概述 简介 CAKeyframeAnimation又称关键帧动画 CAKeyframeAnimation是抽象类CAPropertyAnimation的子类,可以直接使用 通过values与path两 ...

  3. 核心动画 - CAKeyframeAnimation 简单应用

    核心动画: 登录按钮的抖动效果: CAKeyframeAnimation * kfAnimation = [CAKeyframeAnimation animationWithKeyPath:@&quo ...

  4. OC动画:CAAnimationGroup

    //贝塞尔曲线路径 UIBezierPath *movePath = [UIBezierPath bezierPath]; [movePath moveToPoint:CGPointMake(10.0 ...

  5. iOS动画:CAKeyframeAnimation

    网络中Core Animation类的继承关系图       属性简介 @interface CAKeyframeAnimation : CAPropertyAnimation /* 提供关键帧数据的 ...

  6. OC动画CABasicAnimation

    //1.创建动画 CABasicAnimation *anima=[CABasicAnimation animationWithKeyPath:@"bounds"]; //1.1设 ...

  7. 直播点赞,上升的动画-- CAKeyFrameAnimation

    // //  ViewController.m //  DMHeartFlyAnimation // //  Created by Rick on 16/3/9. //  Copyright © 20 ...

  8. 核心动画(CAKeyframeAnimation)

    Main.storyboard ViewController.m // //  ViewController.m //  8A02.核心动画 - CAKeyframeAnimation // //  ...

  9. iOS开发——图形与动画篇OC篇&图层基本上动画

    图层的一些基本动画效果 #define kRadianToDegrees (radian) (radian * 180.0) / (M_PI) //闪烁 [self.testView.layer ad ...

随机推荐

  1. 基于Java的数据采集(一)

    之前写过2篇关于PHP数据采集入库的文章: 基于PHP数据采集入库(一):http://www.cnblogs.com/lichenwei/p/3872307.html 基于PHP数据采集入库(二): ...

  2. 解决highCharts导出功能汉化问题

    本文以highCharts中文网上的例子为原型,处理解决highCharts导出功能为英文的问题. 我们使用highCharts当然希望所有提示或文本都是中文的了,但是highCharts的默认语言是 ...

  3. [PHP] 06 - Security: Error, Exception and Filter

    前言 Ref: PHP 发送电子邮件 Ref: PHP Secure E-mails PHP发邮件部分在此系列中略. 这里展开”安全“相关的部分. 有啥区别?  Ref: PHP异常与错误处理机制 P ...

  4. 对osg节点添加glsl特效(片断着色器FragmentShader)

    读取一个模型到节点node,然后想对node施加一些特效,这时可以只使用片段着色器 其中: gl_Color表示固定管线计算出来的颜色,包含光照效果 gl_TexCoord[]表示纹理坐标 unifo ...

  5. android下载网络图片并缓存

    异步下载网络图片,并提供是否缓存至内存或外部文件的功能 异步加载类AsyncImageLoader public void downloadImage(final String url, final ...

  6. php实现多域名共享session会话

    php会话机制参考:我的随笔 缘起 网站,通常会有多个服务器,多个子域名,每个节点运行着不同模块.有时为了整体体验,用户用同一个用户名.密码浏览整站,不用重复登录.这时候就需要多服务器共享sessio ...

  7. es7 class装饰器

    文档http://es6.ruanyifeng.com/#docs/decorator ts文档 https://www.tslang.cn/docs/handbook/decorators.html ...

  8. IT资源关东煮第一期【来源于网络】

    IT资源关东煮第一期[来源于网络] 地址:http://geek.csdn.net/news/detail/128222

  9. datagrid--新增

    先在datagrid中添加toolbar配置项,增删改差的按钮,有3个属性,按钮名称,图标,回调函数,点击按钮会弹出一个对话框dialog,dialog是关闭的,closed=true, toolba ...

  10. MVC 二级联动

    后台代码,获取数据如下: /// <summary> /// 获取省份 /// </summary> public JsonResult GetProvincelist() { ...