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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
// NSObject+WAnimation.h
// WZLBadgeDemo
//
// Created by zilin_weng on 15/6/26.
// Copyright (c) 2015年 Weng-Zilin. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSUInteger, WAxis)
{
WAxisX = 0,
WAxisY,
WAxisZ
};
// Degrees to radians
#define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)
#define RADIANS_TO_DEGREES(radians) ((radians) * (180.0 / M_PI))
@interface CAAnimation (WAnimation)
/**
* breathing forever
*
* @param time duritaion, from clear to fully seen
*
* @return animation obj
*/
+(CABasicAnimation *)opacityForever_Animation:(float)time;
/**
* breathing with fixed repeated times
*
* @param repeatTimes times
* @param time duritaion, from clear to fully seen
*
* @return animation obj
*/
+(CABasicAnimation *)opacityTimes_Animation:(float)repeatTimes durTimes:(float)time;
/**
* //rotate
*
* @param dur duration
* @param degree rotate degree in radian(弧度)
* @param axis axis
* @param repeatCount repeat count
*
* @return animation obj
*/
+(CABasicAnimation *)rotation:(float)dur degree:(float)degree direction:(WAxis)axis repeatCount:(int)repeatCount;
/**
* scale animation
*
* @param fromScale the original scale value, 1.0 by default
* @param toScale target scale
* @param time duration
* @param repeatTimes repeat counts
*
* @return animaiton obj
*/
+(CABasicAnimation *)scaleFrom:(CGFloat)fromScale toScale:(CGFloat)toScale durTimes:(float)time rep:(float)repeatTimes;
/**
* shake
*
* @param repeatTimes time
* @param time duration
* @param obj always be CALayer at present
* @return aniamtion obj
*/
+(CAKeyframeAnimation *)shake_AnimationRepeatTimes:(float)repeatTimes durTimes:(float)time forObj:(id)obj;
/**
* bounce
*
* @param repeatTimes time
* @param time duration
* @param obj always be CALayer at present
* @return aniamtion obj
*/
+(CAKeyframeAnimation *)bounce_AnimationRepeatTimes:(float)repeatTimes durTimes:(float)time forObj:(id)obj;
@end