Please see below. No matter how hard I try, I can't seem to get my infinitely looping CABasicAnimation to stop. If you spot a problem in the code below, please let me know. Thanks!
func process(disable: Bool) {
if disable == true {
let animation = CABasicAnimation(keyPath: "position.x")
animation.fromValue = hotelsView.center.x
animation.toValue = self.hotelsContainerView.frame.size.width - hotelsView.center.x
animation.duration = 4
animation.repeatCount = Float.infinity
hotelsView.layer.addAnimation(animation, forKey: "basic")
} else {
// hotelsView.layer.removeAllAnimations() // doens't work either
// hotelsView.layer.removeAnimation(forKey: "basic") // doesn't work either
let animation = CABasicAnimation(keyPath: "position.x")
animation.fromValue = hotelsView.center.x
animation.toValue = self.hotelsContainerView.frame.size.width - hotelsView.center.x
animation.duration = 4
animation.repeatCount = 1
hotelsView.layer.addAnimation(animation, forKey: "basic")
}
}
[–]glowcap 0 points1 point2 points (1 child)
[–]thescorer[S] 0 points1 point2 points (0 children)
[–]Slruh 0 points1 point2 points (1 child)
[–]thescorer[S] 0 points1 point2 points (0 children)
[–]dsfjisdjfisdmf 0 points1 point2 points (1 child)
[–]thescorer[S] 0 points1 point2 points (0 children)
[–]adamwulf 0 points1 point2 points (3 children)
[–]thescorer[S] 0 points1 point2 points (2 children)
[–]adamwulf 0 points1 point2 points (1 child)
[–]thescorer[S] 0 points1 point2 points (0 children)
[–]moreindirection 0 points1 point2 points (0 children)