Skip to content

Instantly share code, notes, and snippets.

@myrickchow32
Last active January 1, 2019 13:16
Show Gist options
  • Save myrickchow32/7629f905c2cb26bbe9f6fbe7a416435a to your computer and use it in GitHub Desktop.
Save myrickchow32/7629f905c2cb26bbe9f6fbe7a416435a to your computer and use it in GitHub Desktop.
// All animations are done with the same length of duration --- 1.0 second
let durationOfAnimationInSecond = 1.0
func curveAnimation(view: UIView, animationOptions: UIView.AnimationOptions, isReset: Bool) {
let defaultXMovement: CGFloat = 240
UIView.animate(withDuration: durationOfAnimationInSecond, delay: 0, options: animationOptions, animations: {
view.transform = isReset ? .identity : CGAffineTransform.identity.translatedBy(x: defaultXMovement, y: 0)
}, completion: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment