CABasicAnimation的使用方法(移动,旋转,缩放)
来源:互联网 发布:ghost32软件详解 编辑:程序博客网 时间:2024/06/06 02:30
设定动画CABasicAnimation的属性和说明
动画结束后停在最后位置状态的解决方法
animation.fillMode = kCAFillModeForwards;
1.移动动画
animation.beginTime =CACurrentMediaTime() + 1;// 1秒后执行
animation.fromValue = [NSValue valueWithCGPoint:myView.layer.position]; // 起始帧
animation.toValue = [NSValue valueWithCGPoint:CGPointMake(300, 300)]; // 终了帧
// 视图添加动画
[View.layer addAnimation:animation forKey:@"move-layer"];
2.旋转动画
animation.duration = 2;
animation.repeatCount = 2;
animation.beginTime = CACurrentMediaTime() + 1; // 1秒后执行
animation.fromValue = [NSNumber numberWithFloat:0.0]; // 起始角度
animation.toValue = [NSNumber numberWithFloat:M_PI]; // 终止角度
[View.layer addAnimation:animation forKey:@"rotate-layer"];
3.缩放动画
[myView.layer addAnimation:animation forKey:@"scale-layer"];
4.渐隐动画
//opacity 指layer的透明度
CABasicAnimation *basicAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
basicAnimation.fromValue = @(1.0);
basicAnimation.toValue = @(0.0);//[NSNumber numberWithFloat:0.0]
basicAnimation.duration = 1.5;
[self.myView.layer addAnimation:basicAnimation forKey:@"op"];
5.组合动画
6.捕获动画开始时和终了时的事件
- (void)animationDidStart:(CAAnimation *)theAnimation {- CABasicAnimation的使用方法(移动,旋转,缩放)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- CABasicAnimation的基本使用方法(移动·旋转·放大·缩小)
- ef增删改查
- POJ 2031 ZOJ 1718 Building a Space Station
- 数据库基础定义
- XListView下拉刷新,上拉加载和ListView多条目加载
- div宽高监控
- CABasicAnimation的使用方法(移动,旋转,缩放)
- node.js基础学习--IO-对象映射(fs,Buffer)
- 第一章:pip 安装 tar.gz 结尾的文件 和 .whl 结尾的文件
- Android开源库V
- 中西方的信仰差异
- VB.NET在WinCE5.0中异常转储试验
- Java 集合系列07之 Stack源码解析
- 算法复习:栈的压入、弹出序列
- python2.7版本链接MySQL数据库