IOS 之关键帧动画-CAKeyframeAnimation

//长按左右晃动的幅度大小
    CGFloat shake = 10;
    
    CAKeyframeAnimation *keyAnim = [CAKeyframeAnimation animation];
    keyAnim.keyPath = @"transform.translation.x";
    keyAnim.values = @[@(-shake), @(shake), @(-shake)];
    keyAnim.removedOnCompletion = NO;
    keyAnim.repeatCount = MAXFLOAT;
    //左右晃动一次的时间
    keyAnim.duration = 0.3;
    [self.layer addAnimation:keyAnim forKey:@"shake"];


你可能感兴趣的:(IOS 之关键帧动画-CAKeyframeAnimation)