不多说 直接上代码吧
#pragma mark -抖动动画
- (void)shaking:(IconView *)view {
CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];
anim.keyPath = @"transform.rotation";
anim.values = @[@(Angle2Radian(-5)), @(Angle2Radian(5)), @(Angle2Radian(-5))];
anim.duration = 0.25;
//动画的重复执行次数
anim.repeatCount = MAXFLOAT;
//保持动画执行完毕后的状态
anim.removedOnCompletion = NO;
anim.fillMode = kCAFillModeForwards;
[view.layer addAnimation:anim forKey:@"shake"];
}