Skip to content

Instantly share code, notes, and snippets.

@thanhzusu
Created April 29, 2020 03:22
Show Gist options
  • Save thanhzusu/bce9bcd6dcf0214e017e7387d112ddc8 to your computer and use it in GitHub Desktop.
Save thanhzusu/bce9bcd6dcf0214e017e7387d112ddc8 to your computer and use it in GitHub Desktop.
iOS - Basic Animation
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