Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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