Ios 图像在设置动画之前正在跳跃

Ios 图像在设置动画之前正在跳跃,ios,objective-c,animation,Ios,Objective C,Animation,我目前有一个点击按钮的图像动画,但问题是图像在开始动画之前从故事板上的位置跳转。我不明白它为什么这样做——我只想把它从屏幕上的当前位置移到右边 我是做错了什么,还是错过了什么 原始位置: [self moveImage:_cornerCloud duration:3.0 curve:UIViewAnimationOptionCurveLinear x:200.0 y:0]; - (void)moveImage:(UIImageView *)image duratio

我目前有一个点击按钮的图像动画,但问题是图像在开始动画之前从故事板上的位置跳转。我不明白它为什么这样做——我只想把它从屏幕上的当前位置移到右边

我是做错了什么,还是错过了什么

原始位置:

[self moveImage:_cornerCloud duration:3.0
              curve:UIViewAnimationOptionCurveLinear x:200.0 y:0];
- (void)moveImage:(UIImageView *)image duration:(NSTimeInterval)duration
        curve:(int)curve x:(CGFloat)x y:(CGFloat)y
{

// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];

// The transform matrix
CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y);
image.transform = transform;

// Commit the changes
[UIView commitAnimations];
}

动画开始:

[self moveImage:_cornerCloud duration:3.0
              curve:UIViewAnimationOptionCurveLinear x:200.0 y:0];
- (void)moveImage:(UIImageView *)image duration:(NSTimeInterval)duration
        curve:(int)curve x:(CGFloat)x y:(CGFloat)y
{

// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];

// The transform matrix
CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y);
image.transform = transform;

// Commit the changes
[UIView commitAnimations];
}

移动图像触发器:

[self moveImage:_cornerCloud duration:3.0
              curve:UIViewAnimationOptionCurveLinear x:200.0 y:0];
- (void)moveImage:(UIImageView *)image duration:(NSTimeInterval)duration
        curve:(int)curve x:(CGFloat)x y:(CGFloat)y
{

// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];

// The transform matrix
CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y);
image.transform = transform;

// Commit the changes
[UIView commitAnimations];
}
移动图像功能:

[self moveImage:_cornerCloud duration:3.0
              curve:UIViewAnimationOptionCurveLinear x:200.0 y:0];
- (void)moveImage:(UIImageView *)image duration:(NSTimeInterval)duration
        curve:(int)curve x:(CGFloat)x y:(CGFloat)y
{

// Setup the animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];

// The transform matrix
CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y);
image.transform = transform;

// Commit the changes
[UIView commitAnimations];
}

这应该会容易一点。

您应该使用
[UIView animateWithDuration:…]