shu223 / PulsingHalo

iOS Component for creating a pulsing animation.
MIT License
1.77k stars 240 forks source link

Pulsing animation removed after bringing app back to the foreground #16

Closed ddewaele closed 9 years ago

ddewaele commented 9 years ago

When the demo app is running and the home button is pressed, the app is pushed to the background. When the app is launched again. the pulsing animation is gone.

What would be the correct hook to bring the animation back on the screen ?

unmutedev commented 9 years ago

For us we see it going away even when you present a view controller over a view controller that has a pulsing halo. Would love an explanation on this!

ddewaele commented 9 years ago

@Unmute I have a simple app where a new viewcontroller is pushed onto the stack via a navigation controller, and the pulsing halo (placed on the first viewcontroller) was also shown on the second viewcontroller. I thought this was normal behaviour.

I had to remove it by executing the following code :

[self.halo removeAllAnimations];
[self.halo removeFromSuperlayer];
unmutedev commented 9 years ago

In the latest version there was an addition starting on line 105 in PulsionHaloLayer.m of the CAAnimationGroup delegate method. This method seems to be called when pushing a view controller or presenting one which in turn removes the animation. I added the if (flag) then remove the animations as that signals the animation is truly done. I am unsure if this is correct but for now until I revisit the code it will have to do. Below is my code for that method which would not remove the animation when a view controller is pushed or presented.

goelv commented 9 years ago

@Unmute thanks a lot for your suggestion. I experienced the exact same issue as you and your suggestion about has helped me fix it.

genaks commented 8 years ago

Does not work for me

shu223 commented 8 years ago

I created updated version named "Pulsator" which is written in Swift.

https://github.com/shu223/Pulsator

This problem has been fixed at the repo. Usage is almost same.