0

我在触发滑动事件时运行此代码,它在淡出时显示一个放大的箭头,如您所见,我将图像的位置设置为与滑动位置相同的位置,但它仅从上一个位置开始touch was(在完成块中设置)。但是在我设置更新位置的方法开始时,为什么它从上一次触摸的位置开始动画?

    static bool isAnimating;
- (void)animateImageZoom: (UIImageView *)imageView startingAtLocation:(CGPoint)location inDirection: (FadeDirection)direction
{
    if (!isAnimating) {
        CGRect previousFrame = imageView.frame;
        imageView.frame = CGRectMake(location.x, location.y, previousFrame.size.width, previousFrame.size.height);
        imageView.hidden = NO;


        [UIView animateWithDuration:0.6f
                              delay:0.3f
                            options:UIViewAnimationOptionBeginFromCurrentState
                         animations:^(void) {
                             isAnimating = YES;
                             imageView.alpha = 0;

                             // ZOOM
                             if (direction == fadeLeft) {
                                 imageView.frame = CGRectMake(location.x,
                                                              location.y, 256, 256);
                             } else if (direction == fadeRight) {
                                 imageView.frame = CGRectMake(location.x,
                                                              location.y, 256, 256);
                             }
                         }
                         completion:^(BOOL finished) {
                             isAnimating = NO;

                             imageView.frame = CGRectMake(location.x, location.y, previousFrame.size.width, previousFrame.size.height);
                             imageView.hidden = YES;
                             imageView.alpha = 0.8f;
                         }];
    }
}
4

0 回答 0