Skip to content

Instantly share code, notes, and snippets.

@alexnikol
Last active Apr 26, 2020
Embed
What would you like to do?
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