Created
March 4, 2016 22:17
-
-
Save erikfloresq/bcb99f3633a9e4f544cc to your computer and use it in GitHub Desktop.
Shake animation for element, for example UITextField
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
class func shakeThis(element:UIView) { | |
element.transform = CGAffineTransformMakeTranslation(-20, 0) | |
UIView.animateWithDuration(0.8, delay: 0.0, usingSpringWithDamping: 0.3, initialSpringVelocity: 0.5, options: UIViewAnimationOptions.CurveEaseInOut, animations: { () -> Void in | |
element.transform = CGAffineTransformIdentity | |
}, completion: nil) | |
// iphoneVibrate | |
//AudioServicesPlayAlertSound(kSystemSoundID_Vibrate) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment