//    方法一 用法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. 从vboot来看:virtualbox 和 vmware 虚拟化软件环境的兼容性(支持能力)的差距真是挺大的!

    仅仅就支持vboot启动来说:vwmare 完胜!! 熬了一周,(当前最新版本)用virtualbox 5.22 和 6.0 总是无法完成vboot的正常启动功能:不是蓝屏.就是死慢.要不就直接han ...

  2. [原]openstack-kilo--issue(十八) Error parsing template file: Template format version not found.

    在创建stack的时候出现的报错: ]# heat stack-create nems_demo -e AAA.yaml -f AAA.parameter.yaml Error parsing tem ...

  3. POJ 3249 Test for Job

    Test for Job Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 13457 Accepted: 3100 Descrip ...

  4. SharePoint2013与SharePoint2016语言切换原理以及如何使用代码进行语言切换

    1.前言 在SharePoint 2010版本,在首页面直接"选择显示语言"的菜单(如下图所示),如下图 : 在sharepoint2013和sharepoint2016并非如此. ...

  5. onems设备管理系统(TR-069和OMA)

    onems设备管理系统(TR-069和OMA) 沃克斯科技OneMS设备管理套件是一个全面的为服务提供商和企业提供自动配置和远程管理功能的设备管理解决方案.它利用现有的网络基础设施来自动化订购,预配置 ...

  6. web初级开发的那些坑

    1.在使用js原生的XMLHttpRequest加载.xml文件时,老是不对,按照书上的写的没错,后来才发现是我的web.xml文件中阻止了.xml文件的加载. 2.有关于string解析成json数 ...

  7. 设备重力感应 window.DeviceOrientationEvent

    设备屏幕方向与运动 https://developers.google.cn/web/fundamentals/native-hardware/device-orientation/ MDN devi ...

  8. matplotlib --> r`$...$`

    文档中介绍的很详细:https://matplotlib.org/tutorials/text/mathtext.html matplotlib  Tutoials --> Text --> ...

  9. 快速排序中的partition.

    经典快速排序中的partition, 将最后一个元素作为划分点. 维护两个区域. <= x 的, >x 的区域. 划分过程中还有个待定的区域. [L,less] 区域小于x, [less+ ...

  10. HDU 4699 - Editor - [对顶栈]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4699 Problem Description Sample Input8I 2I -1I 1Q 3LD ...