CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];
animation.keyPath = @"position.x";//左右晃动 position.y上下晃动
animation.values = @[@0,@10,@-10,@10,@0];//位置点
animation.keyTimes = @[@0,@(1/6.0),@(3/6.0),@(5/6.0),@1];//时间点
animation.duration = 0.2f;//晃动持续时间
animation.additive = YES;
[shakeView.layer addAnimation:animation forKey:@"shake"];
网友评论