POP(来自非死book)自定义动画的一个扩展:MMTweenAnimation
jopen
10年前
POP(来自非死book)自定义动画的一个扩展。源于 tweaner(https://code.google.com/p/tweaner), MMTweanerAnimation 提供了10种不同的自定义动画。
Back | Bounce | Circ | Cubic | Elastic |
---|---|---|---|---|
![]() | ![]() | ![]() | ![]() | ![]() |
Expo | Quad | Quart | Quint | Sine |
---|---|---|---|---|
![]() | ![]() | ![]() |
To apply a MMTweenAnimation, you must configure it by:
@property (nonatomic, copy) MMTweenAnimationBlock animationBlock; @property (nonatomic, assign) double fromValue; @property (nonatomic, assign) double toValue; @property (nonatomic, assign) double duration; //default: 0.3 @property (nonatomic, assign) MMTweenFunctionType functionType; //default: MMTweenFunctionBounce @property (nonatomic, assign) MMTweenEasingType easingType; //default: MMTweenEasingOut
for example:
MMTweenAnimation *anim = [MMTweenAnimation animation]; anim.functionType = MMTweenFunctionBounce; anim.easingType = MMTweenEasingOut; anim.duration = 2.0f; anim.fromValue = 0; anim.toValue = 200; anim.animationBlock = ^(double c,double d,double v,id target,MMTweenAnimation *animation) { //c: current time, from the beginning of animation //d: duration, always bigger than c //v: value, after the change at current time UIView *t = (UIView*)target; t.center = CGPointMake(t.x, v); }; [targetView pop_addAnimation:anim forKey:@"center.y"];