MatiBot / MBCircularProgressBar

A circular, animatable & highly customizable progress bar from the Interface Builder (Objective-C)
https://www.cocoacontrols.com/controls/mbcircularprogressbar
MIT License
994 stars 180 forks source link

animation of circular progress bar fails if it goes to background and comes back to foreground #62

Closed Duraiamuthan closed 6 years ago

Duraiamuthan commented 6 years ago

Let's say my animation time is 30 seconds and I will have progress bar reached to 55 when 30 seconds are over.but If I push the app to background and bring it to foreground then the progress bar has reached to 55 even though 30 seconds are not over yet.

 [UIView animateWithDuration:5.f animations:^{
        self.progressBar.value = 55.f;
    }];
Duraiamuthan commented 6 years ago

Tried pausing and resuming the layer as per apple documentation but still not working.

Please find the sample code here

MatiBot commented 6 years ago

That's tricky, maybe as a workaround you can, upon going to background, save the time and when the user comes back again calculate the difference in time and set the animation again. that should work for now.

Duraiamuthan commented 6 years ago

Yes that's right.But pausing and resuming the animation at layer level would be a best option rather than starting the animation on our own again.IfpauseLayer is called on applicationWillResignActive it stops the animation and doesn't let the animation go to value 55 when the app is brought to foreground but now resumeLayer is not working as expected.so now the scenario is that the animation is frozen with the value it had when the app was going background.If I could find a way I will keep it posted here.