// 视图抖动动画
+ (
void
)shakeView:(
UIView
*)view
duration
:(CGFloat)fDuration
{
if
(view && (fDuration >=
0
.1f
))
{
CABasicAnimation* shake = [
CABasicAnimation
animationWithKeyPath
:
@"transform.rotation.z"
];
//设置抖动幅度
shake
.fromValue
= [
NSNumber
numberWithFloat
:-
0
.3
];
shake
.toValue
= [
NSNumber
numberWithFloat
:+
0
.3
];
shake
.duration
=
0
.1f
;
shake
.repeatCount
= fDuration/
4
/
0
.1f
;
shake
.autoreverses
=
YES
;
[view
.layer
addAnimation
:shake
forKey
:
@"shakeView"
];
}
else
{}
}