Created
April 29, 2020 03:22
-
-
Save thanhzusu/bce9bcd6dcf0214e017e7387d112ddc8 to your computer and use it in GitHub Desktop.
iOS - Basic Animation
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
private func animationGroup(animations:[CAAnimation])->CAAnimationGroup{ | |
let keyframe = CAAnimationGroup() | |
keyframe.animations = animations | |
keyframe.duration = 0.7 | |
keyframe.repeatCount = 0 | |
keyframe.delegate = self | |
return keyframe | |
} | |
private func move(fromValue:CGFloat, toValue:CGFloat)->CABasicAnimation{ | |
let keyframe = CABasicAnimation(keyPath: "position.x") | |
keyframe.duration = 0.7 | |
keyframe.fromValue = fromValue | |
keyframe.toValue = toValue | |
keyframe.repeatCount = 0 | |
return keyframe | |
} | |
private func rotate(fromValue:CGFloat, toValue:CGFloat)->CABasicAnimation{ | |
let keyframe = CABasicAnimation(keyPath: "transform.rotation.z") | |
keyframe.additive = true; | |
keyframe.duration = 0.7 | |
keyframe.fromValue = fromValue | |
keyframe.toValue = toValue | |
keyframe.repeatCount = 0 | |
return keyframe | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment