ios - 图像在动画之前跳跃

标签 ios objective-c animation

我目前有一个单击按钮时会产生动画的图像,但问题是该图像在开始动画之前从 Storyboard 上的位置跳转。我无法弄清楚它为什么要这样做 - 我只想将其从屏幕上的当前位置移到右侧。

我是否做错了什么,或者只是错过了什么?

原始位置:

original

动画开始:

original

移动图像触发器:

[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/

相关文章:

java - Android ListView 向右滑动以显示按钮

javascript - 如何为 Canvas 上的绘图线设置动画

ios - FireBase PhoneAuth 线程 1 : Fatal error: Unexpectedly found nil while unwrapping an Optional value

ios - 在 drawRect 中用两种不同的字体绘制一个 NSString?

ios - 如何在 View Controller 中使用自定义类?

iphone - 如何在 iPhone 应用程序中使用 ABAddressBookRef?

ios - UIButtons 在动画期间没有响应 - iOS Swift 3

ios - 这是内存崩溃吗? NSZombies 没有捕获它

objective-c - 可以使用为自动合成属性创建的实例变量吗?

objective-c - NSSpeechRecognizer 和 .delegate=self;问题