简单动画之输入框抖动效果
2016-09-01 本文已影响0人
iCoders
抖动效果
/**
*为textField扩展一个左右晃动的动画
*/
- (void)shake {
CAKeyframeAnimation*keyFrame = [CAKeyframeAnimationanimationWithKeyPath:@"position.x"];
keyFrame.duration=0.3;
CGFloatx =self.layer.position.x;
keyFrame.values=@[@(x -30),@(x -30),@(x +20),@(x -20),@(x +10),@(x -10),@(x +5),@(x -5)];
[self.layeraddAnimation:keyFrameforKey:@"shake"];
}