代码实例:

【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. Web Api通过Route、RoutePrefix等特性设置路由

    [Route("customers/{customerId}/orders")] [HttpGet] public IEnumerable<Order> FindOrd ...

  2. sql server 字符串函数str()

    语法: STR(nExpres[,nLength[,nDecimalPlaces]]) 参数: nExpression------STR要计算的数值表达式. nLength------------ST ...

  3. [BZOJ1016][JSOI2008]最小生成树计数(结论题)

    题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1016 分析: 首先有个性质:如果边集E.E'都可以表示一个图G的最小生成树(当然E和E ...

  4. SVN——配置和安装

    SVN安装步骤: 所有安装文件下载地址:http://pan.baidu.com/s/1bocNTDl 一.安装01----VisualSVN-Server-3.4.2-x64.msi 文件 直接下一 ...

  5. Go加密解密之DES

    一.DES简介 DES(Data Encryption Standard)是对称加密算法,也就是加密和解密用相同的密钥.其入口参数有三个:key.data.mode.key为加密解密使用的密钥,dat ...

  6. Go--避免SQL注入

    避免SQL注入 什么是SQL注入 SQL注入攻击(SQL Injection),简称注入攻击,是Web开发中最常见的一种安全漏洞.可以用它来从数据库获取敏感信息,或者利用数据库的特性执行添加用户,导出 ...

  7. "此站点已经禁用应用程序"在sharepoint 2013中通过v2013部署app提示该错误

    该错误的原文是:the apps are disabled in this site 可以在yahoo或者bing上搜索这个错误,可以找到解决办法: msdn上也有该错误解决办法,但是如果搜索中文,目 ...

  8. 修改placehosder

    CSS美化INPUT placeholder效果.CSS代码美化文本框里的placeholder文字. ::selection伪元素 简而言之:单冒号(:)用于CSS3伪类,双冒号(::)用于CSS3 ...

  9. Maven-搭建普通maven项目

    点击Eclipse菜单栏File->New->Ohter->Maven得到如下图所示对话框: 选中Maven Project并点击Next,到下一个对话框(默认)继续点击Next得到 ...

  10. maven-修改本地仓库存放地址

    eclipse中增加maven的插件,maven默认的本地库的路径是 ${user}/.m2/repository/下 一般windows用户的操作系统都安装在C盘 C:\Users\admin\.m ...