Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created May 20, 2020 14:17
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 stevencurtis/baf3f54539d430a12f25672e60f3c024 to your computer and use it in GitHub Desktop.
Save stevencurtis/baf3f54539d430a12f25672e60f3c024 to your computer and use it in GitHub Desktop.
animatekeyframes
UIView.animateKeyframes(withDuration: 5.0, delay: 0.0, options: [], animations: {
UIView.addKeyframe(withRelativeStartTime: 0.0, relativeDuration: 0.25, animations: {
self.coverView.alpha = 0.0
self.coverBottomConstraint = newBottomConstraint
self.view.layoutIfNeeded()
})
UIView.addKeyframe(withRelativeStartTime: 0.2, relativeDuration: 0.25, animations: {
self.setupMoveCenter()
})
UIView.addKeyframe(withRelativeStartTime: 0.4, relativeDuration: 0.25, animations: {
self.moveCenter.center = self.view.center
})
UIView.addKeyframe(withRelativeStartTime: 0.6, relativeDuration: 0.25, animations: {
self.setupConstraintsViewAndAnimate()
})
UIView.addKeyframe(withRelativeStartTime: 0.8, relativeDuration: 0.25, animations: {
self.combinationView.backgroundColor = .blue
self.combinationView.frame = CGRect(x: 200, y: 500, width: 200, height: 200)
self.view.addSubview(self.combinationView)
let translate = CGAffineTransform(translationX: 100, y: 100)
let rotate = CGAffineTransform(rotationAngle: 1600)
let scale = CGAffineTransform(scaleX: 0.5, y: 0.5)
self.combinationView.transform = translate.concatenating(rotate).concatenating(scale)
})
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment