代码实例:

【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. 如何在Vue2中实现组件props双向绑定

    Vue学习笔记-3 前言 Vue 2.x相比较Vue 1.x而言,升级变化除了实现了Virtual-Dom以外,给使用者最大不适就是移除的组件的props的双向绑定功能. 以往在Vue1.x中利用pr ...

  2. Linux权限

    在Linux中要修改一个文件夹或文件的权限我们需要用到linux chmod命令来做,下面我写了几个简单的实例大家可参考一下. 语法如下: chmod [who] [+ | - | =] [mode] ...

  3. HDInsight - 1,简介

    最近工作需要,要看HDInsight部分,这里要做笔记.自然是官网资料最权威,所以内容都从这里搬过来:https://azure.microsoft.com/en-us/documentation/a ...

  4. Linux配置无线网卡驱动实现无线上网

    本机装Linux,需要配置的无线驱动.一般Ubuntu都集成无线驱动,基本上无线可以直接使用! 01.查看无线网卡的型号 [root@Mr-zhao software]# lspci    | gre ...

  5. C++类功能扩展预留五招

    第一招虚函数 通过派生类来进行功能扩展是基本的面向对象的方式,这种方式大如下: class base { public: virtual ~base(){} virtual void fun() { ...

  6. python环境搭建-Linux系统下python2.6.6升级python3.5.2步骤

    [root@template ~]# python -v # /usr/lib64/python2.6/encodings/utf_8.pyc matches /usr/lib64/python2.6 ...

  7. Criteria查询之sqlRestriction()的理解

    sqlRestriction()的理解 在Criteria查询中 使用sqlRestriction()方法来提供SQL语法作限定查询,作为where字句 查看官方给的例子,如下 List cats = ...

  8. oracle判断字段是否存在语句

    declare v_cnt number; begin select count(*) into v_cnt from dba_tab_columns where table_name='T_IDC_ ...

  9. 一个简单的网页布局HTML+CSS

    <!doctype html> <html> <head> <meta charset="utf-8"/> <title> ...

  10. Java学习之ConcurrentHashMap实现一个本地缓存

    ConcurrentHashMap融合了Hashtable和HashMap二者的优势. Hashtable是做了线程同步,HashMap未考虑同步.所以HashMap在单线程下效率较高,Hashtab ...