IOS UITextField incorrect animation, iosuitextfield
// Left and right vibrations
-(Void) shake :( UIView *) view {
CGRect frame = view. frame;
CAKeyframeAnimation * shakeAnimation = [CAKeyframeAnimation animationWithKeyPath: @ "position"];
CGMutablePathRef shakePath = CGPathCreateMutable ();
CGPathMoveToPoint (shakePath, NULL, frame. origin. x + frame. size. width/2, frame. origin. y + frame. size. height/2 );
Int index;
For (index = 3; index> = 0; -- index ){
CGPathAddLineToPoint (shakePath, NULL, frame. origin. x + frame. size. width/2-frame. size. width * 0.02f * index, frame. origin. y + frame. size. height/2 );
CGPathAddLineToPoint (shakePath, NULL, frame. origin. x + frame. size. width/2 + frame. size. width * 0.02f * index, frame. origin. y + frame. size. height/2 );
}
CGPathCloseSubpath (shakePath );
ShakeAnimation. path = shakePath;
ShakeAnimation. duration = 0.5f;
ShakeAnimation. removedOnCompletion = YES;
[View. layer addAnimation: shakeAnimation forKey: nil];
CFRelease (shakePath );
}