Reputation: 4481
I've been trying to animate ASDisplayNode for a while now, without any real progress.
I've read and try lots of examples, including the Texture transition API https://texturegroup.org/docs/layout-transition-api.html.
I would like to use a callback animation frame so I can coordinate the property change of some elements over time.
While using with UIKit I've been using https://github.com/timdonnelly/Advance which has a very simple API that hooks to DisplayLink and provide simple callbacks on value change overtime.
At the very least I would like a very simple animation of height to work:
UIView.animate(withDuration: 0.5, delay: 0, options: .curveEaseInOut, animations: {
self.height = 500
})
And it doesn't. Furthermore, I would even prefer a callback animation where I get a callback (overtime) whenever displaying is ideal (similar to Displaylink).
Thanks!
Upvotes: 2
Views: 667
Reputation: 87
Using CABasicAnimation I was able to animate a node:
let scaleAnimation = CABasicAnimation(keyPath: "transform.scale")
scaleAnimation.fromValue = 0.9
scaleAnimation.toValue = 1.3
scaleAnimation.duration = 1.0
scaleAnimation.repeatCount = .infinity
let fadeAnimation = CABasicAnimation(keyPath: "opacity")
fadeAnimation.fromValue = 1
fadeAnimation.toValue = 0
fadeAnimation.duration = 1.0
fadeAnimation.repeatCount = .infinity
DispatchQueue.main.async {
nodeToAnimate.layer.add(scaleAnimation, forKey: "scale")
nodeToAnimate.layer.add(fadeAnimation, forKey: "opacity")
}
Upvotes: 0