我目前有一个单击按钮时会产生动画的图像,但问题是该图像在开始动画之前从 Storyboard 上的位置跳转。我无法弄清楚它为什么要这样做 - 我只想将其从屏幕上的当前位置移到右侧。
我是否做错了什么,或者只是错过了什么?
原始位置:
动画开始:
移动图像触发器:
[self moveImage:_cornerCloud duration:3.0
curve:UIViewAnimationOptionCurveLinear x:200.0 y:0];
moveImage函数:
- (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:3.0f
delay:0.0f
options:UIViewAnimationOptionCurveLinear
animations:^{
// just set the center to off-screen
}
completion:^(BOOL finished){}];
这应该容易一点。
关于ios - 图像在动画之前跳跃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17728442/