视图抖动动画
视图抖动动画
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | // 视图抖动动画 + (void)shakeView:(UIView*)view duration:(CGFloat)fDuration { if (view && (fDuration >= 0.1f)) { CABasicAnimation* shake = [CABasicAnimationanimationWithKeyPath:@"transform.rotation.z"]; //设置抖动幅度 shake.fromValue= [NSNumbernumberWithFloat:-0.3]; shake.toValue= [NSNumbernumberWithFloat:+0.3]; shake.duration= 0.1f; shake.repeatCount= fDuration/4/0.1f; shake.autoreverses= YES; [view.layeraddAnimation:shakeforKey:@"shakeView"]; }else{} } |