FRTextFieldAnimation
该库在文本字段被选中时显示了美丽的占位符动画
示例
要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install
。
要求
- Swift 4.0 或更高版本
- iOS 8.0
- XCode 9.0
安装
Cocoapods
如果需要,安装 Cocoapods。
$ gem install cocoapods
在您的 Podfile
中添加 FRTextFieldAnimation
。
use_frameworks!
pod 'FRTextFieldAnimation'
然后,运行以下命令。
$ pod install
使用方法
在此处找到iOS的示例代码。
初始化
import FRTextFieldAnimation
@IBOutlet weak var textView: FRTextFieldAnimation!
textView.placeHolderFont = UIFont.boldSystemFont(ofSize: 20)
textView.textFieldFont = UIFont.boldSystemFont(ofSize: 15)
textView.placeHolderTitle = "Phone number"
textView.placeHolderColor = UIColor.red
textView.lineColor = UIColor.purple
textView.textColor = UIColor.darkGray
textView.textLimit = 11
textView.keyboardType = .numberPad
如果你想使用textfield的代理方法
textView.delegate = self
extension ViewController: AnimatedTextInputDelegate {
func animatedTextInputDidEndEditing(animatedTextInput: FRTextFieldInput) {
//code
}
func animatedTextInputDidBeginEditing(animatedTextInput: FRTextFieldInput) {
//code
}
func animatedTextInputDidChange(animatedTextInput: FRTextFieldInput) {
//code
}
func animatedTextInputShouldReturn(animatedTextInput: FRTextFieldInput) -> Bool {
animatedTextInput.resignFirstResponder()
return true
}
func animatedTextInputShouldBeginEditing(animatedTextInput: FRTextFieldInput) -> Bool {
return true
}
func animatedTextInputShouldEndEditing(animatedTextInput: FRTextFieldInput) -> Bool {
return true
}
}
作者
Farshad Ghafari, [email protected]
许可证
FRTextFieldAnimation采用MIT许可证。有关更多信息,请参阅LICENSE文件。