Skip to content

Instantly share code, notes, and snippets.

@sjehutch
Last active January 27, 2018 17:10
Show Gist options
  • Save sjehutch/bd7057347f5ad2b1ad1c9e3a8918c3df to your computer and use it in GitHub Desktop.
Save sjehutch/bd7057347f5ad2b1ad1c9e3a8918c3df to your computer and use it in GitHub Desktop.
rotate image-swift
extension UIView {
func rotate360Degrees(duration: CFTimeInterval = 3) {
let rotateAnimation = CABasicAnimation(keyPath: "transform.rotation")
rotateAnimation.fromValue = 0.0
rotateAnimation.toValue = CGFloat(Double.pi * 2)
rotateAnimation.isRemovedOnCompletion = false
rotateAnimation.duration = duration
rotateAnimation.repeatCount=Float.infinity
self.layer.add(rotateAnimation, forKey: nil)
}
///Call it sample
syncAllBtn.imageView?.rotate360Degrees()
//syncAllBtn.imageView?.rotate360Degrees(duration: 5)
syncAllBtn.isEnabled = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment