Changing properties of control hangs animation block
yarivadam opened this issue · comments
Bug Report
Version
Unpublished beta version
Overview of what you tried to do
Fade progress ring inside animation block
What is the expected outcome?
Progress ring alpha fades to 0 within animation block, completion called
What is the actual outcome?
when I do that, the animation block never gets to the completion block! what I see is that the alpha property was set on the progress ring (it disappears), but the knob remains visible and is unaffected.
Post sample code or example here
If sample code can't be provided because it's too long, please provide a small example project,
where I can test, if you cannot provide either. There is not much I can do.
I noticed a weird issue that I think may have something to do with the fix you implemented. I think you may want to look into it.
When switching states in my application I use some animations when removing some UI controls. So when I switch from a "playing" state to "stopped", for example, I want the progress ring to fade, and then I remove it, using something like this:
UIView.animate(withDuration: 0.4, delay: 0.0, options: .curveEaseOut, animations: {
self.progressRing.alpha = 0.0
}) { (success) in
self.progressRing.resetProgress()
self.progressRing.removeFromSuperview()
}
However, when I do that, the animation block never gets to the completion block! what I see is that the alpha property was set on the progress ring (it disappears), but the knob remains visible and is unaffected. I'm not sure what's going on, but because of the strange behavior of the knob not getting the alpha set to 0 I'm assuming it may have something to do with your code change.
I wasn't sure if to write this here (for context) or open a new issue.
Regards,
Yariv.
Have you tried fixing this yourself?
This project is open source, and I'm a student with very minimal amount of time.
Please give an attempt at fixing the issue first before creating a bug report.
This saves everyone time and benefits anyone who uses the library.
Pull requests are welcome!
Hi there, why are you calling self.progressRing.removeFromSuperView()
? Also, in order to help I need some more details, like where are you calling the animate function, is it from the main thread?
To animate view hiding should be as simple as:
UIView.animate(withDuration: 0.4, options: .curveEaseOut) {
self.progressRing.alpha = 0.0 // or self.progressRing.isHidden = true
}
I'm calling removeFromSuperview() because I don't want the progress bar to stay there after hiding it. I'm doing exactly what you wrote in your response, except that in the UIView.animate() completion block I'm removing it from the superview.
I'll have to check the animation code to answer your request for details... maybe that's my bug, calling on another thread.