代码实例:

【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. jQuery操作单选按钮(radio)用法

    1.获取选中值,四种方法都可以: $('input:radio:checked').val():$("input[type='radio']:checked").val(); $( ...

  2. Castle 多继承选择

    Castle 多继承选择 很多时候,我们定义了一个接口,但是这个接口会有多种不同的,这时IOC构造函数注入的时候,就需要自动选择对应的实现. public interface ITestService ...

  3. Javascript/jQuery 获取地址栏URL参数的方法

    1.jquery获取url很简单,代码如下 window.location.href; 2.javascript获取url参数 function getUrlParam(name) { var reg ...

  4. 前端 head 中mate 详解

    <meta name="viewport" content="width=device-width,height=device-height,initial-sca ...

  5. [Ajax系列]Ajax介绍

    Ajax简介: Ajax是一种在无需重新加载整个网页的情况下,能够更新部分网页的技术. What ? AJAX=异步JavaScript和XML AJAX是一种用于创建快读动态网页的技术 通过在后台语 ...

  6. 数据结构——动态链表(C++)

    定义一个节点: [cpp] view plain copy   print? #include <iostream> using namespace std; typedef int T; ...

  7. 如何调试js文件

    来源于:http://stackoverflow.com/questions/988363/how-can-i-debug-my-javascript-code http://stackoverflo ...

  8. Spring 向页面传值以及接受页面传过来的参数的方式

    来源于:http://www.cnblogs.com/liuhongfeng/p/4802013.html 一.从页面接收参数 Spring MVC接收请求提交的参数值的几种方法: 使用HttpSer ...

  9. display~

  10. Mycat+Mysql 插入数据报错 i[Err] 1064 - partition table, insert must provide ColumnList

    使用Navicat连接Mycat 8066 成功插入了分库表和全局表 1.全局表 sql如下: '); '); '); 插入成功! 2.分库表 sql如下: ', null, null, null, ...