Skip to content

Instantly share code, notes, and snippets.

@alexnikol
Last active April 26, 2020 16:09
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 alexnikol/3a9ac90265f4c325aa62d416d343b2d1 to your computer and use it in GitHub Desktop.
Save alexnikol/3a9ac90265f4c325aa62d416d343b2d1 to your computer and use it in GitHub Desktop.
CABasicAnimation example
// MARK: Position Animation
let positionAnimation = CABasicAnimation(keyPath: #keyPath(CALayer.position))
positionAnimation.fromValue = CGPoint(x: -20, y: 100)
positionAnimation.toValue = CGPoint(x: 280, y: 100)
positionAnimation.duration = globalDuration
positionAnimation.repeatCount = globalRepeatCount
positionAnimation.autoreverses = true
// MARK: Add Animation to Layer
view.layer.add(positionAnimation, forKey: #keyPath(CALayer.position))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment