Last active
January 27, 2018 17:10
-
-
Save sjehutch/bd7057347f5ad2b1ad1c9e3a8918c3df to your computer and use it in GitHub Desktop.
rotate image-swift
This file contains hidden or 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
| 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