//长按左右晃动的幅度大小
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
最新推荐文章于 2021-03-29 15:38:55 发布