How do I simultaneously animate a UIImageView's image and the UIImageView itself?

后端 未结 4 1958
余生分开走
余生分开走 2020-12-16 08:26

The title may not be so clear, but what I want to do is to make the UIImageView display a series of images (sort of like a gif) and I do this by setting the animationI

4条回答
  •  甜味超标
    2020-12-16 09:06

    I've just done something similar. The code I used looks like this:

        CGRect r = ziv.frame;
        r.origin.x += WrongDistance;
        [ziv startAnimating];
        [UIView animateWithDuration:3.0 animations:^(void){
            [ziv setFrame:r];
        } completion:^(BOOL finished){
    
            [ziv stopAnimating];
    
            if (finished){
                // not canceled in flight
                if (NumWrong == MaxWrong)
                    [self endOfGame:NO];
                else
                    [self nextRound:self];
            }
        }];
    

    Perhaps the issue you're running into is because both animations are on the same thread?

提交回复
热议问题