I have a custom animator for view controller interactive transition. There is also a blur effect that is set to nil depending on the transition progress. The effect's animation code is the following:
@objc func blurEffectDissmisal() {
    UIView.animate(withDuration: dismissAnimator.durationOfAnimation + 1, animations: {
        self.blurEffectView?.effect = nil
    }) { (done) in
        if (done) {
       self.blurEffectView?.removeFromSuperview()
        }
    }
}
I call it by a notification, which is called on the second view controller when the transition from it to the first one starts. 
However, I have a problem here. The completion block is called before the animation ends. When I run the transition for the first time (without canceling it) it works fine, but during the subsequents runs it doesn't.
I had also tried to add the animation to my animator but it didn't work out, either.
Moreover, the completion block gets called before the actual animation ends when I cancel the transition (in this case, I understand why but can't figure out how to make it move backwards. Maybe I should create a reverse animation in a completion block?)
I have tried the suggestion from this answer as you can see, but doesn't help.
If you know how this problem could be solved, I would really appreciate your help.
 
     
    
 
    