宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-04-13 2da4b661c52c12a94eee6b9c2bc156a0fbc04a45
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
//
//  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