ios 三种基本动画
来源:互联网 发布:中国移动网络维护 编辑:程序博客网 时间:2024/06/05 02:47
转载自:http://www.2cto.com/kf/201402/278925.html
第一种 隐式动画
这是一种最简单的动画,不用设置定时器,不用考虑线程或者重画
实现代码:
#import
1
2
3
4
5
6
7
8
9
-(
void
)clickButton:(UIButton*)button
{
[UIView beginAnimations:nil
context:nil];
CGAffineTransform transform=CGAffineTransformMakeTranslation(
180
,
200
);
[self.imageView.layer setAffineTransform:transform];
self.imageView.layer.opacity=
1
;
[UIView commitAnimations];
}
操作layer,IOS的动画都是操作layer
第二种、显示动画
1
2
3
4
5
6
7
8
9
10
11
12
13
CABasicAnimation *opAnim=[CABasicAnimation animationWithKeyPath:@
"opacity"
];
opAnim.duration=
6.0
;
opAnim.fromValue=[NSNumber numberWithFloat:
25
];
opAnim.toValue=[NSNumber numberWithFloat:
1.0
];
opAnim.cumulative=YES;
opAnim.repeatCount=
1
;
[self.imageView.layer addAnimation:opAnim forKey:@
"animateOpacity"
];
CGAffineTransform moveTransform=CGAffineTransformMakeTranslation(
200
,
200
);
CABasicAnimation *moveAnim=[CABasicAnimation animationWithKeyPath:@
"transform"
];
moveAnim.duration=
6.0
;
moveAnim.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(moveTransform)];
[self.imageView.layer addAnimation:moveAnim forKey:@
"animateTransform"
];
第三种、关键帧显示动画
1
2
3
4
5
6
7
8
9
10
11
12
CAKeyframeAnimation *opAnim=[CAKeyframeAnimation animationWithKeyPath:@
"opacity"
];
opAnim.duration=
6.0
;
opAnim.values=@[
@0
.25,
@0
.75,
@1
.0];
opAnim.keyTimes=@[
@0
.0,
@0
.5,
@1
.0];
[self.imageView.layer addAnimation:opAnim forKey:@
"animateOpacity"
];
CGAffineTransform moveTransform=CGAffineTransformMakeTranslation(
180
,
200
);
CABasicAnimation *moveAnim=[CABasicAnimation animationWithKeyPath:@
"transform"
];
moveAnim.duration=
6.0
;
moveAnim.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(moveTransform)];
moveAnim.delegate=self;
[self.imageView.layer addAnimation:moveAnim forKey:@
"animateTransform"
];
values是一个值的数组
keyTimes是一个每个帧片段持续的时间比例,取值范围是0.0-1.0之前
0 0
- ios 三种基本动画
- 三种基本动画
- IOS 三种动画
- iOS的三种动画
- IOS三种动画总结
- IOS 基本 动画
- iOS基本动画
- ios动画学习(三)
- iOS:核心动画之基本动画CABasicAnimation
- IOS之 基本动画原理
- ios 动画的基本使用
- IOS之 基本动画原理
- iOS核心动画基本要点
- IOS之CAAnimation基本动画
- Android三种动画的基本实现总结
- 零基础学习IOS开发(三)- cocos2d-x3.0 显示图像及基本动画效果
- Android三种动画(属性、视图、帧动画)介绍基本使用
- iOS 常用的三种动画表现效果
- redhat上安装clusterssh
- linux下C语言操作MySQL数据库
- Problem E
- C/C++中static用法小结
- OLAP的一些相关概念
- ios 三种基本动画
- Percona Xtrabackup
- poj 3321 Apple Tree 树状数组
- 怎样快速在线将pdf转换成word
- JDeveloper different library list deteected
- 算法学习 - 括号匹配(栈实现)C++
- 四:Smack文档的下载和初步了解
- android学习之路
- 中国的车祸为什么多?一个”海归”的亲身体验