Last active
January 3, 2020 19:40
-
-
Save agammahajan1/1b480982b4bb5e46c4c453e88d1bd159 to your computer and use it in GitHub Desktop.
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
func addAnimation(firstImageView: UIImageView, secondImageView: UIImageView) { | |
let basicAnimation1 = getBasicAnimation(withInitialPostion: centerPosition, finalPos: finalPosition) | |
firstImageView.layer.add(basicAnimation1, forKey: "position") | |
let basicAnimation2 = self.getBasicAnimation(withInitialPostion: self.initalPosition, finalPos: self.centerPosition) | |
secondImageView.layer.add(basicAnimation2, forKey: "position") | |
self.addNextImage(forImageView: firstImageView) | |
} | |
func getBasicAnimation(withInitialPostion initialPos: CGPoint, finalPos: CGPoint) -> CABasicAnimation { | |
let basicAnimation = CABasicAnimation(keyPath: "position") | |
basicAnimation.fromValue = NSValue(cgPoint: initialPos) | |
basicAnimation.toValue = NSValue(cgPoint: finalPos) | |
basicAnimation.duration = 1 | |
basicAnimation.isRemovedOnCompletion = false | |
basicAnimation.fillMode = CAMediaTimingFillMode.forwards | |
basicAnimation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut) | |
return basicAnimation | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment