UITextFieldShakeSwift
  • October 19, 2023

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’

  • Then add import UITextField_Shake_Swift at the top of your Swift class.

  • Finally compile and run and you will be good to go.

####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

// Shake
self.textField.shake()

// Shake with the default speed
self.textField.shake(10, // 10 times
withDelta: 5.0 // 5 points wide
)

// Shake with a custom speed
self.textField.shake(10, // 10 times
withDelta: 5.0, // 5 points wide
speed: 0.03 // 30ms per shake
)

// Shake with a custom speed and direction
self.textField.shake(10, // 10 times
withDelta: 5.0, // 5 points wide
speed: 0.03, // 30ms per shake
shakeDirection: ShakeDirection.Vertical
)

####Completion Handler You can also pass a closure that will be run as soon as the shake animation stops:

// Using the trailing closure syntax
self.textField.shake(10, withDelta: 5.0) {
() -> Void in
println(“Called after TextField ended up shaking”)
}

GitHub


View Github

#animation #awesemetextfield #carthage #cocoapods #currencytextfield #customtextfield #customwidgets #draganddrop #facetedsearch #geosearch #growingtextview #instantsearch #interfacebuilder #ios #ioslibrary #iosswift #objectivec #opensource #passwordtextfield #placeholder #placeholdertextview #realmswift #search #searchengine #searchinterface #searchsynonyms #styledtext #swift #swiftframework #swiftlibrary #swiftpackagemanager #swiftui #swiftuicomponents #text #textexpansion #textfield #texture #textview #tjtextfield #ui #uikit #uitextfield #uitextfieldnavigation #uitextview #uitextviewalgolia #widgets
YOU MIGHT ALSO LIKE...
exyte

     

camerakit-ios

CameraKit helps you add reliable camera to your app quickly. Our open source camera platform provides consistent capture results, service ...

HybridCamera

[video width="192" height="416" mp4="https://swiftgit.com/wp-content/uploads/2024/12/68747470733a2f2f7261776769742e636f6d2f7374796c656b69742f696d672f6d61737465722f7669645f6564697465645f325f326d622e676966.mp4"][/video]

TakeASelfie

An iOS framework that uses the front camera, detects your face and takes a selfie. This api opens the front ...

iOS-Depth-Sampler

Code examples of Depth APIs in iOS