ZLAnimationTool.m
1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// ZLAnimationTool.m
// 多选相册照片
//
// Created by long on 15/11/26.
// Copyright © 2015年 long. All rights reserved.
//
#import "ZLAnimationTool.h"
@implementation ZLAnimationTool
+ (CATransition *)animateWithType:(NSString *)type subType:(NSString *)subType duration:(CFTimeInterval)duration
{
CATransition *animate = [CATransition animation];
[animate setDuration:duration];
[animate setType:type];
[animate setSubtype:subType];
[animate setTimingFunction:UIViewAnimationCurveEaseInOut];
return animate;
}
+ (CABasicAnimation *)animateWithFromValue:(id)fromValue toValue:(id)toValue duration:(CFTimeInterval)duration keyPath:(NSString *)keyPath
{
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:keyPath];
animation.fromValue = fromValue;
animation.toValue = toValue;
animation.duration = duration;
animation.repeatCount = 0;
animation.autoreverses = NO;
//以下两个设置,保证了动画结束后,layer不会回到初始位置
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
return animation;
}
+ (CAKeyframeAnimation *)animateWithBtnStatusChanged
{
CAKeyframeAnimation *animate = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
animate.duration = 0.3;
animate.removedOnCompletion = YES;
animate.fillMode = kCAFillModeForwards;
animate.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.7, 0.7, 1.0)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.8, 0.8, 1.0)],
[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
return animate;
}
@end