UITextField-Shake-Swift
UITextField extension in Swift that adds shake animation
Initially created by Andrea Mazzini (using Objective-C) on 08/02/14: https://github.com/andreamazz/UITextField-Shake
Translated by myself from Objective-C to Swift and provided to you on this repository.
##Setup with CocoaPods (recommended setup)
- Add the instructions below to your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
pod 'UITextField-Shake-Swift'
####Otherwise you can also manually import the framework
Just drag and drop UITextFieldShakeSwift/UITextFieldShakeSwift/UITextField+Shake.swift
file into your Xcode project and do not forget to check the checkbox entitled "Copy items if needed" and the appropriate checkboxe(s) in "Add to targets" section.
##Usage
###In Swift
self.textField.shake()
self.textField.shake(10,
withDelta: 5.0
)
self.textField.shake(10,
withDelta: 5.0,
speed: 0.03
)
self.textField.shake(10,
withDelta: 5.0,
speed: 0.03,
shakeDirection: ShakeDirection.Vertical
)
####Completion Handler
You can also pass a closure that will be run as soon as the shake animation stops:
self.textField.shake(10, withDelta: 5.0) {
() -> Void in
println("Called after TextField ended up shaking")
}