Skip to content

Instantly share code, notes, and snippets.

@Callonski
Last active September 20, 2017 14:15
Show Gist options
  • Save Callonski/577feeef2ca4538c8aa14f86c1645a18 to your computer and use it in GitHub Desktop.
Save Callonski/577feeef2ca4538c8aa14f86c1645a18 to your computer and use it in GitHub Desktop.
Animations
// Enkelt animation
UIView.animate(withDuration: 1, animations: {
})
// Animera med funktion efter klar
UIView.animate(withDuration: 0.2, animations: {
// Animera
}) { _ in
// Klarkod
}
// Animation med mer inställningar
UIView.animate(withDuration: 1, delay: 1, options: .curveEaseIn, animations: {
// Animation
}) { _ in
// Klarkod
}
// Rotera en vy
let halfRotation = CGFloat(M_PI)
self.fish.transform = CGAffineTransform(rotationAngle: halfRotation)
// Keyframes
let duration = 2.0
let delay = 0.0
let options = UIViewKeyframeAnimationOptions.calculationModeLinear
UIView.animateKeyframes(withDuration: 1, delay: 1, options: options, animations: {
// Animera
}) { _ in
// Klarkod
}
UIView.animateKeyframes(withDuration:, delay: delay, options: options, animations: {
UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 1/3, animations: {
// Animera
})
UIView.addKeyframe(withRelativeStartTime: 1/3, relativeDuration: 1/3, animations: {
// Animera
})
UIView.addKeyframe(withRelativeStartTime: 2/3, relativeDuration: 1/3, animations: {
// Animera
})
}) { _ in
// Klarkod
}
myView.transform = CGAffineTransform(scaleX: 2, y: 2)
myView.transform = CGAffineTransform(translationX: 100, y: 100)
myView.transform = CGAffineTransform(rotationAngle: CGFloat.pi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment