- (void)createBaseAnimation{

//基础动画

CABasicAnimation *animation = [CABasicAnimation animation];

animation.keyPath = @"bounds";

//    animation.fromValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 300, 300)];//默认为现在的状态

animation.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 300, 300)];

animation.duration = 2;

animation.removedOnCompletion = NO;  //动画之后保持最新

animation.fillMode = kCAFillModeForwards;  //最新样式

animation.delegate = self;

[view.layer addAnimation:animation forKey:nil];

}

- (void)animationDidStart:(CAAnimation *)anim{

NSLog(@"动画开始时调用");

}

- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{

NSLog(@"动画结束时调用");

}

- (void)createKeyFrameAnimation{

//帧动画

CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];

animation.keyPath = @"position";

//路径

//    CGMutablePathRef path = CGPathCreateMutable();

//    CGPathAddEllipseInRect(path, nil, CGRectMake(100, 100, 200, 200));

//

//    animation.path = path;

//注意:与基础动画的区别:可以设置多个点/一堆值

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

NSValue *value2 = [NSValue valueWithCGPoint:CGPointMake(0, 300)];

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

animation.values = @[value1,value2,value3];

//动画的执行节奏

animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

animation.duration = 5;

animation.removedOnCompletion = NO;  //动画之后保持最新

animation.fillMode = kCAFillModeForwards;  //最新样式

[view.layer addAnimation:animation forKey:nil];

}

- (void)createTransiton{

//转场动画

CATransition *animaiton = [CATransition animation];

//动画过渡类型

animaiton.type = @"cube";

//过渡方向

animaiton.subtype = kCATransitionFade;

animaiton.duration = 3;

[view.layer addAnimation:animaiton forKey:nil];

}

- (void)createAnimationGroup{

//动画分组(旋转+缩放)

//1.旋转

CABasicAnimation *rotationAnimaiton = [CABasicAnimation animation];

rotationAnimaiton.keyPath = @"transform.rotation.z";

rotationAnimaiton.toValue = @(M_PI_4 * 3);

rotationAnimaiton.duration = 5;

rotationAnimaiton.repeatCount = MAXFLOAT;

//2.缩放

CABasicAnimation *scaleAnimation = [CABasicAnimation animation];

scaleAnimation.keyPath = @"transform";

scaleAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(2, 2, 0)];

scaleAnimation.duration = 5;

//动画分组

CAAnimationGroup *group = [CAAnimationGroup animation];

group.animations = @[rotationAnimaiton,scaleAnimation];

group.removedOnCompletion = NO;

group.fillMode = kCAFillModeForwards;

group.duration = 5;

[view.layer addAnimation:group forKey:nil];

}

- 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

CoreAnimation 核心动画 / CABasicAnimation/ CAKeyframeAnimation的更多相关文章

  1. IOS 核心动画之CAKeyframeAnimation - iBaby

    - IOS 核心动画之CAKeyframeAnimation - 简单介绍 是CApropertyAnimation的子类,跟CABasicAnimation的区别是:CABasicAnimation ...

  2. iOS开发CoreAnimation解读之一——初识CoreAnimation核心动画编程

    iOS开发CoreAnimation解读之一——初识CoreAnimation核心动画编程 一.引言 二.初识CoreAnimation 三.锚点对几何属性的影响 四.Layer与View之间的关系 ...

  3. 核心动画(CAKeyframeAnimation,CABasicAnimation)

    一,核心动画常用的三种例子 view的核心动画其体现就是把view按照指定好的路径进行运动,针对的是view的整体. [view.layer addAnimation:动画路径 forKey:@“绑定 ...

  4. 核心动画(CAKeyframeAnimation)

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

  5. CoreAnimation 核心动画

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

  6. iOS CoreAnimation 核心动画

    一 介绍 一组非常强大的动画处理API 直接作用在CALAyer上,并非UIView(UIView动画) CoreAnimation是所有动画的父类,但是不能直接使用,应该使用其子类 属性: dura ...

  7. CoreAnimation 核心动画一 (一些常用属性 和 方法)

    1.常用属性: frame   bounds   center   alpha    Transition 过渡    transform 动画效果 2.常用方法: +(void)setAnimati ...

  8. CoreAnimation 核心动画二 锚点

    锚点: anchorPoint     以锚点为中心 执行动画 (与 渔夫固定船的点时一致的) anchorPoint 默认是 0.5,0.5  (注意: 锚点 是一个比例) anchorPoint ...

  9. AJ学IOS(39)UI之核心动画之CABasicAnimation(基础动画)

    AJ分享,必须精品 一.CABasicAnimation简介 CAPropertyAnimation的子类 属性解析: fromValue:keyPath相应属性的初始值 toValue:keyPat ...

随机推荐

  1. weex和vue开发环境配置详解(配置系统变量等等)

    本文详细讲解如何搭建weex和vue开发环境 安装java 现在java安装包,网上的安装包都是国外的,很难下载下来 就用这个链接下载,亲测无毒,http://www.wmzhe.com/soft-3 ...

  2. 具有避障和寻线功能的Arduino小车

    标签:  Arduino  乐高  机器人 创客对于成年人来说,多半是科技娱乐,或者是一种是一种向往科技的人生态度,总是希望自己不仅可以看到或者听到科技的资讯,还希望能够亲身制作科技玩意,从而更好地体 ...

  3. 最全SDWebImage-3.8版本源码阅读详解

    一.前言 SDWebImage,非常友好的网络图片加载第三方框架,在GitHub中已经获得了15000++的star,链接地址:https://github.com/rs/SDWebImage 本人分 ...

  4. linux命令-分区表fstab

    磁盘分区后需要格式化,挂载之后才能使用 我们有开机后自动挂载的需求,方法有两种 1.配置文件的形式,把mount写到配置文件里去 cat /etc/fstab 2.把挂载命令写到一个文件里 ls /e ...

  5. DAY9-python并发之多线程

    一 threading模块介绍 multiprocess模块的完全模仿了threading模块的接口,二者在使用层面,有很大的相似性,因而不再详细介绍 官网链接:https://docs.python ...

  6. MVC5网站部署到IIS7

    server 2008R2+IIS7.5下配置不会出现什么问题,这里记录下在server2008+IIS7下的配置 参考了一下:http://www.cnblogs.com/fcu3dx/p/3773 ...

  7. java中的自动转型的学习理解

    java当中的继承是和c++中的继承类似,只是java中的继承时的父类只能有一位. 我们今天在这里讲的是关于java中的自动转型的理解:顾名思义,自动转型值得就是使用时自动的将自身的类型进行转化. 自 ...

  8. winform combobox绑定数据

    mboBox下拉菜单控件,在数据库内的ComboBox应用的表进行修改时,如果是用的普通方法,显示数据一个方法,添加数据一个方法 这样会导致程序后期维护难度增加,在这里使用数据绑定来让ComboBox ...

  9. windows VS2013 编译安装QWT6.1和QWTPolar1.1.1

    QWT的编译和配置 1. 下载QWT从官网 For getting a snapshot with all bugfixes for the latest 5.2 release: svn expor ...

  10. java中是如何解决编码问题的,比如char类型的对象是如何存储的呢?

    主题句:每个编码形式将字符从字符集转换为编码数据. 说白了一个代码点就是一个Unicode字符.代码单元就是代码点的集合. 字符视图 要了解字符集标准,您必须能区分三种不同的字符视图: 字符集(字符的 ...