Try the following:
[UIView animateWithDuration:0.5 animations:^{ alertView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 200, 0); } completion:^(BOOL finished) { [UIView animateWithDuration:0.5 animations:^{ alertView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, -200, 0); }]; }];
But I would do the animation as follows:
[UIView animateWithDuration:0.1 animations:^{ alertView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 20, 0); } completion:^(BOOL finished) { [UIView animateWithDuration:0.1 animations:^{ alertView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, -20, 0); } completion:^(BOOL finished) { [UIView animateWithDuration:0.1 animations:^{ alertView.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 0, 0); }]; }]; }];
To you !; -)
source share