Last active
April 26, 2020 16:09
-
-
Save alexnikol/3a9ac90265f4c325aa62d416d343b2d1 to your computer and use it in GitHub Desktop.
CABasicAnimation example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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