//
|
// UIView+Animation.m
|
// ZhongTianChuXing
|
//
|
// Created by Marc Michaels on 2018/5/11.
|
// Copyright © 2018年 Marc Michaels. All rights reserved.
|
//
|
|
#import "UIView+Animation.h"
|
|
@implementation UIView (Animation)
|
|
+ (void)popJumpAnimationView:(UIView *)sender {
|
|
CGFloat duration = 0.3;
|
CGFloat height = 7.f;
|
|
CAKeyframeAnimation * animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.y"];
|
CGFloat currentTy = sender.transform.ty;
|
animation.duration = duration;
|
animation.values = @[@(currentTy), @(currentTy - height/4), @(currentTy-height/4*2), @(currentTy-height/4*3), @(currentTy - height), @(currentTy-height/4*3), @(currentTy -height/4*2), @(currentTy - height/4), @(currentTy)];
|
animation.keyTimes = @[ @(0), @(0.025), @(0.085), @(0.2), @(0.5), @(0.8), @(0.915), @(0.975), @(1) ];
|
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
|
animation.repeatCount = 1;
|
[sender.layer addAnimation:animation forKey:@"kViewShakerAnimationKey"];
|
|
}
|
|
@end
|