0

我正在尝试在移动 UIView(带动画)后缩放它(带动画)。问题是,当缩放动画开始时,它会跳回原始位置。为什么?

[UIView animateWithDuration:t delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
    // Drop the ball

    CGRect frame = coinView.frame;
    frame.origin.y += d;

    coinView.frame = frame;

    coinView.shouldSparkle = NO;
} completion:^(BOOL finished) {
    [UIView animateWithDuration:0.3 animations:^{
        // Initial scale up for ball "poof"

        coinView.transform = CGAffineTransformScale(coinView.transform, 1.5, 1.5);
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:0.3 animations:^{
            coinView.transform = CGAffineTransformScale(coinView.transform, 0.000001, 0.000001);
        } completion:^(BOOL finished) {
            [coinView removeFromSuperview];
        }];
    }];
}];

编辑:这就是我生成 d 的方式:

static CGFloat groundPositionY = 325;

CGRect convertedFrame = [coinView.superview convertRect:coinView.frame toView:self.view];

CGFloat d = groundPositionY - CGRectGetMaxY(convertedFrame);

EDIT2:好的,所以我将第二个 UIView 动画更改为以下内容,我发现跳转(和缩小)发生在第二个动画发生之前,即调用 animateWithDuration:delay:options:animations:completion: 时。

[UIView animateWithDuration:5 delay:3 options:0 animations:^{
    coinView.transform = CGAffineTransformScale(coinView.transform, 1.5, 1.5);
} completion:nil];
4

2 回答 2

1

我测试了你的代码,它对我来说很好。你如何生成你的d?它到底回到了哪个街区?

于 2013-01-04T18:59:26.073 回答
0

我发现了问题...

coinView 是子视图控制器视图的子视图。问题来自这样一个事实,即我覆盖了子视图控制器的viewDidLayoutSubviews方法来布置所有的coinView',因此每当调用该方法时,硬币视图都会移回子视图控制器预期的原始位置和大小。

感谢您的所有帮助,repoguy 和塞尔吉奥!!

于 2013-01-04T21:13:10.097 回答