1. 基本使用

UIView * view = [[UIView alloc]initWithFrame:CGRectMake(50, 50, 50,50)];

view.backgroundColor = [UIColor orangeColor];

[self.view addSubview:view];

/////

CABasicAnimation * anim = [CABasicAnimation animationWithKeyPath:@"transform.scale"];

anim.duration = 0.5;

anim.repeatCount = 1;

anim.fromValue = @1;

anim.toValue = @0.3;

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

这个动画的作用是,view的大小在0.5秒之内,缩小到原来的30%,然后迅速的回到原来的大小。

如果anim.autoreverses 设置为YES的话,那就不是“迅速”变为原来的大小,而是从30%的大小反过来变成原来的大小,时间也未duration的值。

这里的 duration为一个repeat的时间,也就是说,如果repeatCount为10,那其实就是10个duration的时间(如果duration为YES的话,还需要*2)

如何让动画结束后保持动画后的状态?

   上面的例子我们看到,动画在结束的时候,返回到原来的大小了,那么如何才能使得动画结束后保持在30%的状态呢?

如下两个语句可以满足:anim.removedOnCOmpletion = NO;  anim.fillMode = kCAFillModeForwards;

2.keypath 可以取值如下

transform.scale = 比例轉換

transform.scale.x = 闊的比例轉換

transform.scale.y = 高的比例轉換

transform.rotation.z = 平面圖的旋轉

opacity = 透明度

margin

zPosition

backgroundColor    背景颜色

cornerRadius    圆角

borderWidth

bounds

contents

contentsRect

cornerRadius

frame

hidden

mask

masksToBounds

opacity

position

shadowColor

shadowOffset

shadowOpacity

shadowRadius

CABasicAnimation 使用的更多相关文章

  1. 基本动画CABasicAnimation - 完成之后闪回初始状态

    基本动画CABasicAnimation 结束之后,默认闪回初始状态,那怎么解决呢? position需要设备两个属性: // MARK: - 结束后不要闪回去 anim.removedOnCompl ...

  2. CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)

    出处:http://blog.csdn.net/iosevanhuang/article/details/14488239 CABasicAnimation类的使用方式就是基本的关键帧动画. 所谓关键 ...

  3. CABasicAnimation的delegate的坑

    博客已经迁移到 www.chjsun.top 在自定义动画的时候,CABasicAnimation用的还算的蛮多的. 在此先介绍一下CABasicAnimation怎么使用. 属性介绍  属性 说明 ...

  4. 之一:CABasicAnimation - 基本动画

    嗷呜嗷呜嗷呜 // 将视图作为属性方便后面执行多个不同动画 _myView = [[UIView alloc] init]; _myView.layer.position = CGPointMake( ...

  5. iOS - CABasicAnimation

    代码实例: [1] - (void)pulseClick { //!> 宽和高等比例转换 CABasicAnimation * pulse = [CABasicAnimation animati ...

  6. 核心动画基础动画(CABasicAnimation)关键帧动画

    1.在iOS中核心动画分为几类: 基础动画(CABasicAnimation) 关键帧动画(CAKeyframeAnimation) 动画组(CAAnimationGroup) 转场动画(CATran ...

  7. CABasicAnimation 按home键后台之后,再切回来动画就停止了

    解决方法: 1. CABasicAnimation *thisAnimation = [CABasicAnimtaion animationWithKeyPath:@"transform.r ...

  8. CABasicAnimation animationWithKeyPath 一些规定的值

    CABasicAnimation animationWithKeyPath Types When using the ‘CABasicAnimation’ from the QuartzCore Fr ...

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

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

  10. 动画 CABasicAnimation animationWithKeyPath 一些规定的值

    CABasicAnimation animationWithKeyPath Types When using the ‘CABasicAnimation’ from the QuartzCore Fr ...

随机推荐

  1. SDUT2142数据结构实验之图论二:基于邻接表的广度优先搜索遍历

    http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2142&cid=1186 题目描述 给定一个无向连通图,顶点编号从0到n-1,用广度优先搜 ...

  2. hdu 4111 Alice and Bob 博弈论

    这里有2种方法: 方法一:求SG函数 sg[i][j]:i表示1的个数,j表示合并操作的步数. 这共有4种操作: 1.消除一个1: 2.减掉一个1: 3.合并2个1: 4.把1合并到另外不是1中. 代 ...

  3. Linux Versus Windows, Ubuntu/Mint V XP/Vista/7

    原文:http://petermoulding.com/linux_versus_windows_ubuntu_mint_v_xp_vista_7 Linux Versus Windows, Ubun ...

  4. Hadoop基础教程之搭建开发环境及编写Hello World

    整个Hadoop是基于Java开发的,所以要开发Hadoop相应的程序就得用JAVA.在linux下开发JAVA还数eclipse方便. 1.下载 进入官网:http://eclipse.org/do ...

  5. HTML5入门4---HTML5 与 HTML4 同一网页的不同写法

    HTML4写法 css: body { font-family: "Lucida Sans Unicode", "Lucida Grande", Verdana ...

  6. Delphi判断字符串是否是数字、字母、大小写字母

    function IsNumberic(Vaule:String):Boolean; //判断Vaule是不是数字 var i:integer; begin result:=true; //设置返回值 ...

  7. TCP digest

    TCP在网络OSI的七层模型中的第四层——Transport层,IP在第三层——Network层,ARP在第二层——Data Link层,在第二层上的数据,我们叫Frame,在第三层上的数据叫Pack ...

  8. 怎么在eclipse里调试WebDriver的源代码

    当你看完WebDriver的工作原理这篇博客以后,是不是也跃跃欲试想印证文章里的理论是不是正确,想自己也看下webdriver的源代码,并且调试下,通过代码来更深入的了解WebDriver的工作原理. ...

  9. AsciiDoc Markup Syntax Summary

    AsciiDoc Markup Syntax Summary ============================== A summary of the most commonly used ma ...

  10. heatmap.2

    heatmap.2 {gplots} R Documentation Enhanced Heat Map Description A heat map is a false color image ( ...