2017-07-04 6 views
0

私のCALayerでアニメーションを作成しようとしていますが、アニメーションレイヤーが表示されません。私はここで間違って何をやっている:CALayerで画像をアニメーション化する方法

return CALayer().build { 

     let myLayer = CALayer() 

     let animation = CAKeyframeAnimation(keyPath: "contents") 
     animation.fillMode = kCAFillModeForwards 
     animation.duration = 3 
     animation.values = TimeLineVC.likeInteractionArray.map { 
      $0.cgImage as AnyObject 
     } 
     animation.repeatCount = 3 

     myLayer.frame = $0.bounds 
     myLayer.add(animation, forKey: "contents") 
     $0.insertSublayer(myLayer, above: $0) 
     myLayer.backgroundColor = UIColor.black.cgColor 


     } 

答えて

0

それはいくつかのプロパティを追加した後に私の仕事:

let animation = CAKeyframeAnimation(keyPath: "contents") 
     animation.calculationMode = kCAAnimationDiscrete 
     animation.duration = 3.0 
     animation.repeatCount = .greatestFiniteMagnitude 
     animation.autoreverses = false 
     animation.values = TimeLineVC.likeInteractionArray.map {$0.cgImage!} 
     animation.isRemovedOnCompletion = false 
     animation.fillMode = kCAFillModeForwards 
     animation.beginTime = 0.0 
     $0.add(animation, forKey: "contents") 
関連する問題