iOS中图标的抖动

整理地址

#define ShakingRadian(R) ((R) / 180.0 * M_PI)

#pragma mark - 抖动动画

- (void)shaking:(UIView *)view {

CAKeyframeAnimation *anim = [CAKeyframeAnimation animation];

anim.keyPath = @"transform.rotation";

anim.values = @[@(ShakingRadian(-5)),  @(ShakingRadian(5)), @(ShakingRadian(-5))];

anim.duration = 0.25;

// 动画的重复执行次数

anim.repeatCount = MAXFLOAT;

// 保持动画执行完毕后的状态

anim.removedOnCompletion = NO;

anim.fillMode = kCAFillModeForwards;

------------------分割线------------------

//开始动画

[view.layer addAnimation:anim forKey:@"shake"];

//结束动画

[view.layer removeAnimationForKey:@"shake"];

}

你可能感兴趣的:(iOS中图标的抖动)