Skip to content

Instantly share code, notes, and snippets.

@erikfloresq
Created March 4, 2016 22:17
Show Gist options
  • Save erikfloresq/bcb99f3633a9e4f544cc to your computer and use it in GitHub Desktop.
Save erikfloresq/bcb99f3633a9e4f544cc to your computer and use it in GitHub Desktop.
Shake animation for element, for example UITextField
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