Merge pull request #9 from TouchInstinct/fix/focus-bug

Fix. Bug with no-value after textfield lose it focus
This commit is contained in:
Nikolai Ashanin 2017-05-18 23:04:19 +03:00 committed by GitHub
commit 297ef68850
2 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'UIAnimatedTextField'
s.version = '0.1.12'
s.version = '0.1.13'
s.summary = 'UITextField with animated placeholder'
s.description = <<-DESC
This custom control can be used as a replacement for UITextField. It comes with 5 different text types: simple, password, url, tappable, date.

View File

@ -451,7 +451,7 @@ open class UIAnimatedTextField: UIView {
return toolbar
}
private func updateText(from datePicker: UIDatePicker) {
fileprivate func updateText(from datePicker: UIDatePicker) {
selectedDate = datePicker.date
text = datePicker.date.toString(withFormat: dateFormat)
}
@ -511,7 +511,11 @@ extension UIAnimatedTextField: UITextFieldDelegate {
if textField.text?.characters.count ?? 0 == 0 {
setState(toState: .placeholder, duration: UIAnimatedTextField.animationDuration)
}
if let datePicker = textField.inputView as? UIDatePicker {
updateText(from: datePicker)
}
delegate?.animatedTextFieldDidEndEditing?(self)
}