在我的 xcode 项目中,我有一个 UIImage。我想让它从左到右稍微晃动(动画)。我写了这段代码,但是,它不起作用。
-(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];
}
请你告诉我,我怎样才能让我的形象动摇?