Animações que não funcionam no playground ios
Este é o meu método de animação (PreloaderView.swift)
public func performAction(action: PreloaderAction)
{
let highOpacity = CABasicAnimation.init(keyPath: "opacity")
let middleOpacity = CABasicAnimation.init(keyPath: "opacity")
let lowOpacity = CABasicAnimation.init(keyPath: "opacity")
if action == .PreloaderActionNone {
self.thirdShape.removeAllAnimations()
self.firstShape.opacity = 0.3;
self.secondShape.opacity = 0.5
self.thirdShape.opacity = 1.0
} else if action == .PreloaderActionFailure {
UIView.animateWithDuration(2, animations: {
self.thirdShape.strokeColor = UIColor.redColor().CGColor
}) {(completed : Bool) in
self.thirdShape.strokeColor = self.ringColor.CGColor
}
}
if action == .PreloaderActionStart {
highOpacity.fromValue = 0.0
highOpacity.toValue = 1.0
highOpacity.duration = animationDuration
highOpacity.autoreverses = true
highOpacity.repeatCount = .infinity
self.secondShape.addAnimation(highOpacity, forKey: "highOpacity")
middleOpacity.fromValue = 0.0
middleOpacity.toValue = 1.0
middleOpacity.duration = animationDuration
middleOpacity.autoreverses = true
middleOpacity.repeatCount = .infinity
middleOpacity.beginTime = CACurrentMediaTime() + 0.33
self.firstShape.addAnimation(middleOpacity, forKey: "middleOpacity")
lowOpacity.fromValue = 0.0
lowOpacity.toValue = 1.0
lowOpacity.duration = animationDuration
lowOpacity.autoreverses = true
lowOpacity.beginTime = CACurrentMediaTime() + 0.66
lowOpacity.repeatCount = .infinity
self.thirdShape.addAnimation(lowOpacity, forKey: "lowOpacity")
}
}
Este é o meu arquivo de recreio
e playground no navegador do projeto
As animações funcionam bem no dispositivo, mas quando uso animações de playground, elas não funcionam.