I have a simple pulse animation which runs perfectly
UIView.animate(withDuration: 1, animations: {
myAnimatableView.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
}) { _ in
UIView.animate(withDuration: 1, animations: {
myAnimatableView.transform = .identity
})
}
I want to make the same animation, but now with UIViewPropertyAnimator. Is it possible to replicate this pulse effect elegantly with the new API?
I'm doing it this way
let animator = UIViewPropertyAnimator(duration: 1, curve: .linear) {
animatableView.transform = CGAffineTransform(scaleX: 1.2, y: 1.2)
}
animator.addCompletion { _ in
animator.isReversed = true
animator.startAnimation()
}
animator.startAnimation()
but my animatableView is just stuck scaled to 1.2.