- IOS 核心动画之CAKeyframeAnimation

- 简单介绍

是CApropertyAnimation的子类,跟CABasicAnimation的区别是:CABasicAnimation只能从一个数值(fromValue)变到另一个数值(toValue),而CAKeyframeAnimation会使用一个NSArray保存这些数值

- 属性解析:

- values:就是上述的NSArray对象。里面的元素称为”关键帧”(keyframe)。动画对象会在指定的时间(duration)内,依次显示values数组中的每一个关键帧

- path:可以设置一个CGPathRef\CGMutablePathRef,让层跟着路径移动。path只对CALayer的anchorPoint和position起作用。如果你设置了path,那么values将被忽略

- keyTimes:可以为对应的关键帧指定对应的时间点,其取值范围为0到1.0,keyTimes中的每一个时间值都对应values中的每一帧.当keyTimes没有设置的时候,各个关键帧的时间是平分的

- 说明:CABasicAnimation可看做是最多只有2个关键帧的CAKeyframeAnimation

- Values方式:

- CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];

animation.keyPath = @"position";

NSValue *value1=[NSValue valueWithCGPoint:CGPointMake(100, 100)];

NSValue *value2=[NSValue valueWithCGPoint:CGPointMake(200, 100)];

NSValue *value3=[NSValue valueWithCGPoint:CGPointMake(200, 200)];

NSValue *value4=[NSValue valueWithCGPoint:CGPointMake(100, 200)];

NSValue *value5=[NSValue valueWithCGPoint:CGPointMake(100, 100)];

animation.values=@[value1,value2,value3,value4,value5]; animation.repeatCount=MAXFLOAT;

animation.removedOnCompletion = NO;

animation.fillMode = kCAFillModeForwards;

animation.duration = 4.0f;

animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

animation.delegate=self;

[self.myView.layer addAnimation:animation forKey:nil];

- Path方式:

- CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];

animation.keyPath = @"position";

CGMutablePathRef path=CGPathCreateMutable();

CGPathAddEllipseInRect(path, NULL, CGRectMake(150, 100, 100, 100));

animation.path=path;

CGPathRelease(path);

animation.repeatCount=MAXFLOAT;

animation.removedOnCompletion = NO;

animation.fillMode = kCAFillModeForwards;

animation.duration = 4.0f;

animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

animation.delegate=self;

[self.myView.layer addAnimation:animation forKey:nil];

- keyPath可以使用的key

- #define angle2Radian(angle) ((angle)/180.0*M_PI)

- transform.rotation.x 围绕x轴翻转 参数:角度 angle2Radian(4)

transform.rotation.y 围绕y轴翻转 参数:同上

transform.rotation.z 围绕z轴翻转 参数:同上

transform.rotation 默认围绕z轴

transform.scale.x x方向缩放 参数:缩放比例 1.5

transform.scale.y y方向缩放 参数:同上

transform.scale.z z方向缩放 参数:同上

transform.scale 所有方向缩放 参数:同上

transform.translation.x x方向移动 参数:x轴上的坐标 100

transform.translation.y x方向移动 参数:y轴上的坐标

transform.translation.z x方向移动 参数:z轴上的坐标

transform.translation 移动 参数:移动到的点 (100,100)

opacity 透明度 参数:透明度 0.5

backgroundColor 背景颜色 参数:颜色 (id)[[UIColor redColor] CGColor]

cornerRadius 圆角 参数:圆角半径 5

borderWidth 边框宽度 参数:边框宽度 5

bounds 大小 参数:CGRect

contents 内容 参数:CGImage

contentsRect 可视内容 参数:CGRect 值是0~1之间的小数

hidden 是否隐藏

position

shadowColor

shadowOffset

shadowOpacity

shadowRadius

IOS 核心动画之CAKeyframeAnimation - iBaby的更多相关文章

  1. CoreAnimation 核心动画 / CABasicAnimation/ CAKeyframeAnimation

    - (void)createBaseAnimation{ //基础动画 CABasicAnimation *animation = [CABasicAnimation animation]; anim ...

  2. IOS 动画专题 --iOS核心动画

    iOS开发系列--让你的应用“动”起来 --iOS核心动画 概览 通过核心动画创建基础动画.关键帧动画.动画组.转场动画,如何通过UIView的装饰方法对这些动画操作进行简化等.在今天的文章里您可以看 ...

  3. iOS 核心动画 Core Animation浅谈

    代码地址如下:http://www.demodashi.com/demo/11603.html 前记 关于实现一个iOS动画,如果简单的,我们可以直接调用UIView的代码块来实现,虽然使用UIVie ...

  4. iOS核心动画高级技巧之核心动画(三)

    iOS核心动画高级技巧之CALayer(一) iOS核心动画高级技巧之图层变换和专用图层(二)iOS核心动画高级技巧之核心动画(三)iOS核心动画高级技巧之性能(四)iOS核心动画高级技巧之动画总结( ...

  5. iOS核心动画学习整理

    最近利用业余时间终于把iOS核心动画高级技巧(https://zsisme.gitbooks.io/ios-/content/chapter1/the-layer-tree.html)看完,对应其中一 ...

  6. iOS核心动画高级技巧之图层变换和专用图层(二)

    iOS核心动画高级技巧之CALayer(一) iOS核心动画高级技巧之图层变换和专用图层(二)iOS核心动画高级技巧之核心动画(三)iOS核心动画高级技巧之性能(四)iOS核心动画高级技巧之动画总结( ...

  7. iOS核心动画高级技巧之CALayer(一)

    iOS核心动画高级技巧之CALayer(一) iOS核心动画高级技巧之图层变换和专用图层(二)iOS核心动画高级技巧之核心动画(三)iOS核心动画高级技巧之性能(四)iOS核心动画高级技巧之动画总结( ...

  8. iOS核心动画(专用图层篇)

    之前的文章我们了解了Core Animation中图层的一些基础知识.没有看过的传送门在此: iOS核心动画基础篇 那么在了解了这些基础知识之后,接下来进入专用图层的了解 苹果为了方便和性能,封装了几 ...

  9. iOS核心动画高级技巧 - 8

    iOS核心动画高级技巧 - 1 iOS核心动画高级技巧 - 2 iOS核心动画高级技巧 - 3 iOS核心动画高级技巧 - 4 iOS核心动画高级技巧 - 5 iOS核心动画高级技巧 - 6 iOS核 ...

随机推荐

  1. Python爬虫--简单爬取图片

    今天晚上弄了一个简单的爬虫,可以爬取网页的图片,现在现在做一下准备工作. 需要的库:urllib 和 re urllib库可以理解为是一个url下载器,其中有三个重要的方法 urllib.urlope ...

  2. SQL2008根据日志恢复

    --创建测试数据库 CREATE DATABASE Db GO --对数据库进行备份 BACKUP DATABASE Db TO DISK='c:\db.bak' WITH FORMAT GO --创 ...

  3. 使用 supervisor 管理进程

    安装: # yum install python-setuptools # easy_install supervisor 如果已经安装了epel和python-pip, 也可以简单 pip inst ...

  4. 滑动的Button

    在介绍SwitchButton之前,先来看一下系统Button是如何实现的.源码如下: @RemoteView public class Button extends TextView { publi ...

  5. C语言中执行到预编译

    在Linux中,执行命令:gcc -o linux.i linux.c -E

  6. Linux top和负载的说明

    转自:http://bbs.linuxtone.org/thread-1684-1-1.html top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windo ...

  7. CMD执行BCP命令

    C:\>BCP "EXEC GetU '2016-7-11' ,'-1'" queryout "C:\\C3Marketing\SummaryReport_test ...

  8. jquery 新闻滚动效果

    $(function () {     var scrollTimer = null;     var delay = 2000;     //1.鼠标对新闻触发mouseout事件后每2s调用scr ...

  9. JSON上

    关于JSON部分: 目录: 一:定义二:实例三:JSON的语法 一:什么是JSON? 1.JSON:JavaScript 对象表示法(JavaScript Object Notation). 2.JS ...

  10. 彻底删除java*

    提示:先备份重要数据 1. 移除所有 Java相关包 (Sun, Oracle, OpenJDK, IcedTea plugins, GIJ): apt-get update apt-cache se ...