Jak zrobić „wstrząsającą” animację
W moim projekcie xcode mam UIImage. Chcę, aby trząść się (animacja) od lewej do prawej. Napisałem ten kod, jednak nie działa.
-(void)errorShake
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[lockImage setTransform:CGAffineTransformMakeRotation(-5 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(-10 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(-15 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(-20 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(-15 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(-10 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(-5 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(0 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(5 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(10 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(15 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(20 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(15 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(10 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(5 * M_PI / 180.0)];
[lockImage setTransform:CGAffineTransformMakeRotation(0 * M_PI / 180.0)];
[UIView commitAnimations];
}
Czy możesz mi powiedzieć, jak mogę sprawić, że mój obraz się trzęsie?