UIView左右晃动特效
2019-08-29 本文已影响0人
iOS乐乐
-(void)showErrorAnimationIsPassoword:(BOOL)isPassword
{
CAKeyframeAnimation *shakeAnim = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.x"];
shakeAnim.values = @[@-10, @0, @10, @0];
shakeAnim.repeatCount = 3;
shakeAnim.duration = 0.1;
if (isPassword)
{
[self.loginView.passwordView.layer addAnimation:shakeAnim forKey:nil];
}
else
{
[self.loginView.phoneView.layer addAnimation:shakeAnim forKey:nil];
}
}