Skip to content

Instantly share code, notes, and snippets.

@dejanskledar
Created December 20, 2017 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dejanskledar/31e7865215f336b7543784939ddbdb3e to your computer and use it in GitHub Desktop.
Save dejanskledar/31e7865215f336b7543784939ddbdb3e to your computer and use it in GitHub Desktop.
UIView.animateKeyframes(withDuration: 5.0, delay: 0, options: [.calculationModeCubic], animations: {
// Add animations
UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 1.0/5.0, animations: {
view.frame.origin.x += 200
})
UIView.addKeyframe(withRelativeStartTime: 1.0/5.0, relativeDuration: 1.0/5.0, animations: {
view.backgroundColor = .green
})
UIView.addKeyframe(withRelativeStartTime: 2.0/5.0, relativeDuration: 1.0/5.0, animations: {
view.frame.origin.y += 200
})
UIView.addKeyframe(withRelativeStartTime: 3.0/5.0, relativeDuration: 1.0/5.0, animations: {
view.transform = CGAffineTransform.identity.scaledBy(x: 2, y: 2)
})
UIView.addKeyframe(withRelativeStartTime: 4.0/5.0, relativeDuration: 1.0/5.0, animations: {
view.alpha = 0
})
}, completion:{ _ in
print("I'm done!")
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment