- July 30, 2025
- Mins Read
UITextField category that adds a shake animation like the password field of the OsX login screen.
pod ‘UITextField+Shake’, ‘~> 1.2’
Import UITextField+Shake.h
in your controller’s header file, or UITextField_Shake
if you are using the use_frameworks!
directive.
github “andreamazz/UITextField-Shake”
// Shake
[[self.textField] shake];
// Shake with the default speed
[self.textField shake:10 // 10 times
withDelta:5 // 5 points wide
];
// Shake with a custom speed
[self.textField shake:10 // 10 times
withDelta:5 // 5 points wide
speed:0.03 // 30ms per shake
];
// Shake with a custom speed and direction
[self.textField shake:10 // 10 times
withDelta:5 // 5 points wide
speed:0.03 // 30ms per shake
shakeDirection:ShakeDirectionVertical
];
// 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
)
You can also pass a completion block that will be performed as soon as the shake animation stops
– (void)shake:(int)times withDelta:(CGFloat)delta completion:(void((^)()))handler;
– (void)shake:(int)times withDelta:(CGFloat)delta speed:(NSTimeInterval)interval completion:(void((^)()))handler;
– (void)shake:(int)times withDelta:(CGFloat)delta speed:(NSTimeInterval)interval shakeDirection:(ShakeDirection)shakeDirection completion:(void((^)()))handler;
or in Swift using the trailing closure syntax:
textField.shake(10, withDelta: 5) {
println(“done”)
}
PermissionsSwiftUI displays and handles permissions in SwiftUI. It is largely inspired by SPPermissions. The UI is highly customizable and resembles an Apple style. ...
Introduction PagerTabStripView is the first pager view built in pure SwiftUI. It provides a component to create interactive pager views ...
1. Taking Action When a Property Changes: Property Observers Swift lets you observe and respond to changes in a property’s ...