Created
May 18, 2016 12:15
-
-
Save TheCodedSelf/5d4965a01ecc295cfda864c9fe94c1f4 to your computer and use it in GitHub Desktop.
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
import UIKit | |
extension UIView | |
{ | |
func shake() | |
{ | |
let shakeAngle = (5 * M_PI) / 360 | |
let shakeRotation = CAKeyframeAnimation(keyPath: "transform.rotation") | |
shakeRotation.values = [0, shakeAngle, 0, -shakeAngle, 0] | |
shakeRotation.duration = 0.3 | |
shakeRotation.repeatCount = 2 | |
self.layer.addAnimation(shakeRotation, forKey: "shake") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment