Skip to content

Instantly share code, notes, and snippets.

@agibson73
Created March 15, 2017 17:25
Show Gist options
  • Save agibson73/8fcade73cba972fdc153bed1f6217560 to your computer and use it in GitHub Desktop.
Save agibson73/8fcade73cba972fdc153bed1f6217560 to your computer and use it in GitHub Desktop.
CATransaction.begin()
let animation = CABasicAnimation(keyPath: "position")
animation.toValue = NSValue(cgPoint: CGPoint(x: self.view.bounds.width - 100, y: self.view.bounds.height - 100))
animation.fromValue = NSValue(cgPoint: position)
animation.duration = 5
animation.isRemovedOnCompletion = false
animation.fillMode = kCAFillModeForwards
CATransaction.setCompletionBlock({
self.airplane.layer.position = CGPoint(x: self.view.bounds.width - 100, y: self.view.bounds.height - 100)
self.airplane.image = UIImage(named: "crash")
})
self.airplane.layer.add(animation, forKey: nil)
CATransaction.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment