iOS UIView Animation Issue

2020-04-21 06:00发布

I have an issue with a UIView animation when switching between pages in a UITabBarController.

A view in UIViewControllerA is playing the following animation:-

[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveLinear | UIViewAnimationOptionBeginFromCurrentState animations:^{
        CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI);
        self.animationImageView.transform = transform;
    } completion:NULL];

The animation is a custom loading wheel which stops when a song has been loaded.

If I switch between pages, i.e. from UIViewControllerA to UIViewControllerB and then back to A in a UITabController the animation stops. It does not animate again when I try to restart it.

1条回答
Anthone
2楼-- · 2020-04-21 06:29

The answer is simple, reset the transform:

self.animationImageView.transform = CGAffineTransformIdentity;
查看更多
登录 后发表回答