CABasicAnimation 使用
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 使用的更多相关文章
- 基本动画CABasicAnimation - 完成之后闪回初始状态
基本动画CABasicAnimation 结束之后,默认闪回初始状态,那怎么解决呢? position需要设备两个属性: // MARK: - 结束后不要闪回去 anim.removedOnCompl ...
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
出处:http://blog.csdn.net/iosevanhuang/article/details/14488239 CABasicAnimation类的使用方式就是基本的关键帧动画. 所谓关键 ...
- CABasicAnimation的delegate的坑
博客已经迁移到 www.chjsun.top 在自定义动画的时候,CABasicAnimation用的还算的蛮多的. 在此先介绍一下CABasicAnimation怎么使用. 属性介绍 属性 说明 ...
- 之一:CABasicAnimation - 基本动画
嗷呜嗷呜嗷呜 // 将视图作为属性方便后面执行多个不同动画 _myView = [[UIView alloc] init]; _myView.layer.position = CGPointMake( ...
- iOS - CABasicAnimation
代码实例: [1] - (void)pulseClick { //!> 宽和高等比例转换 CABasicAnimation * pulse = [CABasicAnimation animati ...
- 核心动画基础动画(CABasicAnimation)关键帧动画
1.在iOS中核心动画分为几类: 基础动画(CABasicAnimation) 关键帧动画(CAKeyframeAnimation) 动画组(CAAnimationGroup) 转场动画(CATran ...
- CABasicAnimation 按home键后台之后,再切回来动画就停止了
解决方法: 1. CABasicAnimation *thisAnimation = [CABasicAnimtaion animationWithKeyPath:@"transform.r ...
- CABasicAnimation animationWithKeyPath 一些规定的值
CABasicAnimation animationWithKeyPath Types When using the ‘CABasicAnimation’ from the QuartzCore Fr ...
- IOS第18天(5,CABasicAnimation基本动画)
******* #import "HMViewController.h" @interface HMViewController () @property (nonatomic, ...
- 动画 CABasicAnimation animationWithKeyPath 一些规定的值
CABasicAnimation animationWithKeyPath Types When using the ‘CABasicAnimation’ from the QuartzCore Fr ...
随机推荐
- CAS(Compare and Swap)理解
什么叫CAS(Compare and Swap)? 硬件同步原语!! 什么蛋疼的名字,一般人很难理解.根据英文全称翻译==比较与交换,这个名字大致还能理解一点,目前先暂且这么理解吧. 有啥用处? 对 ...
- 什么叫非阻塞io
而一个NIO的实现会有所不同,下面是一个简单的例子: ByteBuffer buffer = ByteBuffer.allocate(48); int bytesRead = inChannel.re ...
- python 模拟浏览器
想用python模拟浏览器访问web的方法测试些东西,有哪几种方法呢? 一类:单纯的访问web,不解析其js,css等. 1. urllib2 #-*- coding:utf-8 -* import ...
- Delphi 7事件的多处理机制
Delphi 7事件的多处理机制Allen Tao2007-08-19 首先解释一下这个题目.在我使用Delphi 7的过程中发现,一个对象的事件只能被一个过程处理.如果多次给这个对象的事件赋给处理事 ...
- esriFeatureType与esriGeometryType的区别与联系
esriFeatureType通常用来表示数据的存储结构,即物理层: esriGeometryType通常用来表示数据的几何形状,即表现层. esriGeometryType枚举类型详解 常量 值 对 ...
- Android LayoutInflater.from(context).inflate
在应用中自定义一个view,需要获取这个view的布局,需要用到 (LinearLayout) LayoutInflater.from(context).inflate(R.layout.conten ...
- mysqldump常用于MySQL数据库逻辑备份
mysqldump常用于MySQL数据库逻辑备份. 1.各种用法说明 A. 最简单的用法: mysqldump -uroot -pPassword [database name] > [dump ...
- openfire开发
openfire github地址:https://github.com/igniterealtime/Openfire 1.下载源代码:http://www.igniterealtime.org/d ...
- 10个最佳的PHP图像操作库
Thomas Boutell 以及众多的开发者创造了以GD图形库闻名的一个图形软件库,用于动态的图形计算. GD提供了对于诸如C, Perl, Python, PHP, OCaml等等诸多编程语言的支 ...
- Android百度地图
帖子 热搜: 二维码 聊天 二维码扫描 传感器 游戏 定位 手势绘图 小项目 相框 绘图 涂鸦 拨打电话 记事本 定时器 通话记录 短信群发 listview 音乐播放器 项目例子 百度地 ...