I'm using a CAKeyFrameAnimation in a similar manner to how it's used on this page. I'm trying to have an action occur at the end of the animation, but I'm not sure how I can go about doing that. I looked through the CAKeyFrameAnimation docs and didn't see anything about a completionHandler or anything, and the only thing I can think to do is to set a timer for the animation length and handle everything after that. I figure there must be some better way to get notified that the animation has completed, but I haven't been able to find a better solution.
Swift
Use CATransaction.setCompletionBlock
as below.
CATransaction.begin()
CATransaction.setCompletionBlock({
view.isHidden = true
})
let animation = CAKeyframeAnimation(keyPath: "position")
animation.path = path
view.layer.add(animation, forKey: "moveIn")
CATransaction.commit()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With