代码实例:

【1】

- (void)pulseClick
{   //!> 宽和高等比例转换
    CABasicAnimation * pulse = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    pulse.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    pulse.duration = 0.1;  //!> 动画持续时间
    pulse.repeatCount = ; //!> 动画重复次数
    pulse.autoreverses = YES;//!> 动画执行完毕是否自动还原(YES就是自动还原到比例为1的状态)

    pulse.fromValue = [NSNumber numberWithFloat:];  //!> 动画执行开始的比例
    pulse.toValue = [NSNumber numberWithFloat:0.5];  //!> 动画执行终点的比例
    [_button.layer addAnimation:pulse forKey:nil];
}

【2】

- (void)pulseClick
{
    CABasicAnimation * pulse = [CABasicAnimation animationWithKeyPath:@"cornerRadius"];
    pulse.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    pulse.duration = ;
    pulse.repeatCount = ;
    pulse.autoreverses = YES;

    pulse.fromValue = [NSNumber numberWithFloat:];
    pulse.toValue = [NSNumber numberWithFloat:];
    [_button.layer addAnimation:pulse forKey:nil];
}

【3】

- (void)pulseClick
{
    CABasicAnimation * pulse = [CABasicAnimation animationWithKeyPath:@"contents"];
    pulse.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    pulse.duration = ;
    pulse.repeatCount = ;
    pulse.autoreverses = YES;
    //!> Contents是CALayer的属性,一般就是用作CGImageRef,常见用法就是下面这种用法;
    pulse.fromValue = (id)[UIImage imageNamed:@"flower"].CGImage;
    pulse.toValue = (id)[UIImage imageNamed:@"leaf"].CGImage;
    [_button.layer addAnimation:pulse forKey:nil];
}

【4】

- (void)pulseClick
{   //!> 一闪一闪的动画效果
    CABasicAnimation * pulse = [CABasicAnimation animationWithKeyPath:@"opacity"];
    pulse.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    pulse.duration     = 0.3;
    pulse.repeatCount  = MAXFLOAT;
    pulse.fillMode     = kCAFillModeForwards;
    pulse.autoreverses = YES;

    pulse.fromValue = [NSNumber numberWithFloat:1.0];
    pulse.toValue   = [NSNumber numberWithFloat:0.2];

    [_button.layer addAnimation:pulse forKey:nil];
}

相信iOS客户端开发工程师都对CABasicAnimation都很了解。所以再补充记录一些笔记,关于animationWithKeyPath:

transform.scale = 比例转换

transfrom.scale.x = 宽的比例转换

transfrom.scale.y = 高的比例转换

transfrom.scale.z = 平面圆的旋转(三维z轴)

shadowColor =

shadowOpacity =

shadowRadius =

frame =

bounds =

hidder =

mask =

masksToBounds =

position =

opacity = 透明度

margin =

zPosition =

cornerRadius = 圆角

backgroundColor = 背景颜色

borderWidth = 边框

contents =

contentsRect =

iOS - CABasicAnimation的更多相关文章

  1. ios之CABasicAnimation

    博主:最近iOS开发中用到CoreAnimation的framework来做动画效果,虽然以前也用过,但一直没有系统学习过,今天看到一篇非常详细的博文(虽然是日语,但真的写的很好),在此翻译出来供大家 ...

  2. iOS开发CABasicAnimation动画理解

    1.CALayer简介 CALayer是个与UIView很类似的概念,同样有backgroundColor.frame等相似的属性,我们可以将UIView看做一种特殊的CALayer.但实际上UIVi ...

  3. IOS第18天(5,CABasicAnimation基本动画)

    ******* #import "HMViewController.h" @interface HMViewController () @property (nonatomic, ...

  4. iOS:核心动画之基本动画CABasicAnimation

    基本动画,是CAPropertyAnimation的子类 属性说明: fromValue:keyPath相应属性的初始值 toValue:keyPath相应属性的结束值 动画过程说明: 随着动画的进行 ...

  5. iOS开发——动画编程Swift篇&(四)CABasicAnimation动画

    CABasicAnimation动画 //CABasicAnimation-不透明度 @IBAction func cabOpacity() { let animation = CABasicAnim ...

  6. iOS Layer CABasicAnimation

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...

  7. CABasicAnimation 基本动画 分类: ios技术 2015-07-16 17:10 132人阅读 评论(0) 收藏

    几个可以用来实现热门APP应用PATH中menu效果的几个方法 +(CABasicAnimation *)opacityForever_Animation:(float)time //永久闪烁的动画 ...

  8. iOS核心动画详解(CABasicAnimation)

    前言 上一篇已经介绍了核心动画在UI渲染中的位置和基本概念,但是没有具体介绍CAAnimation子类的用法,本文将介绍CABasicAnimation及其子类CASpringAnimation的用法 ...

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

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

随机推荐

  1. .net异步编程

    现在电脑大部分都是多核心,在处理多线程方便有很大优势,异步调用方法的时候可以立即返回执行其他程序,进行异步编程会让程序运行效率更高. 我也是刚刚关注异步编程方面知识,也有很多不是很理解,所以想向大神请 ...

  2. BASH 命令以及使用方法小结

    最近工作中需要写一个Linux脚本,用到了很多BASH命令,为了防止以后忘记,在这里把它们一一记下来.可能会比较乱,随便看看就好了.如果有说的不对的地方也欢迎大家指正. 1,export VAR=.. ...

  3. rsync实现负载均衡集群文件同步,搭建线上测试部署环境

    闲来无事,搭建一个负载均衡集群,至于负载均衡集群搭建过程,找时间写下.这次主要写集群之间的文件同步,以及线上测试环境的搭建. 笔者看过很多公司都没有线上测试环境,真是崩溃了,不造怎么确保线上线下环境一 ...

  4. js基础知识温习:Javascript中如何模拟私有方法

    本文涉及的主题虽然很基础,在很多人眼里属于小伎俩,但在JavaScript基础知识中属于一个综合性的话题.这里会涉及到对象属性的封装.原型.构造函数.闭包以及立即执行表达式等知识. 公有方法 公有方法 ...

  5. 踩到一个Emit的坑,留个纪念

    重现代码: var dmFoo = new DynamicMethod("Foo", typeof(void), Type.EmptyTypes); var ilFoo = dmF ...

  6. LaTeX常用数学符号表示方法

    转自:http://www.mohu.org/info/symbols/symbols.htm 常用数学符号的 LaTeX 表示方法 (以下内容主要摘自“一份不太简短的 LATEX2e 介绍”) 1. ...

  7. Ubuntu安装出现左上角光标一直闪解决方式

    Ubuntu安装出现左上角光标一直闪解决方式: 01下载ubunu http://cn.ubuntu.com/download/ 02.软碟通 http://pan.baidu.com/s/1qY8O ...

  8. Windows下Php安装mongodb扩展失败

    查看php版本 下载对应的mongodb插件 将php_mongo.dll文件复制到php安装目录下的ext下 重启apache Apache –k restart 浏览器php.info( )测试 ...

  9. JS跳出框架返回上一页

    链接部分 <a class="link" href="javascript:;" target="_top" onclick=&quo ...

  10. SELinux关闭和开启

    检测Selinux状态 ./usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态 SELinux status: enabled .geten ...