测试已测试 | ✗ |
Lang编程语言 | SwiftSwift |
许可证 | MIT |
发布最终发布 | 2015 年 9 月 |
SPM支持 SPM | ✗ |
维护者 King-Wizard.
Swift 中的 UITextField 扩展,增加了摇动动画
最初由 Andrea Mazzini(使用 Objective-C)于 14 年 2 月 8 日创建:[https://github.com/andreamazz/UITextField-Shake](https://github.com/andreamazz/UITextField-Shake)
我将其从 Objective-C 翻译成 Swift 并提供在此仓库中。
只需将 UITextFieldShakeSwift/UITextFieldShakeSwift/UITextField+Shake.swift
文件拖放到您的 Xcode 项目中,并不要忘记勾选“如有必要,复制项”和“添加到目标”部分中的相应复选框。
// 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
)
您还可以传递一个闭包,它将在摇动动画停止时运行
// Using the trailing closure syntax
self.textField.shake(10, withDelta: 5.0) {
() -> Void in
println("Called after TextField ended up shaking")
}