I have animated a UIScrollView this way:
let anim = CAKeyframeAnimation()
anim.keyPath = "bounds.origin.x"
anim.values = self.animValues
anim.keyTimes = self.animKeyTimes
anim.duration = self.animDuration
anim.additive = true
myScrollView.layer.addAnimation(anim, forKey: "move")
Then when the user taps a Cancel I tried this:
myScrollView.layer.removeAnimationForKey("move")
myScrollView.layer.removeAllAnimations()
Neither one works.
I also tried setting anim.duration = 0.0
. That had no effect.
I can't try doing anything with myScrollView.layer.presentationLayer()
because presentationLayer()
is nil
.
The animations do not need to be paused. They can be completely halted and discarded. They are never restarted.
These animations can be 30 seconds or more. Forcing the user to wait until it's finished is not good UX/UI.
Any help would be greatly appreciated.
Thanks,
David
I had to rebuild my project file for a different problem, and when I tried this again it worked the way it's supposed to!
That's at least the third time I've had to rebuild the project file for this app. I must be doing something right!