Merge pull request #8 from TouchInstinct/bugfix/kvo

Fix. KVO & value passing
This commit is contained in:
Nikolai Ashanin 2017-04-27 13:51:35 +03:00 committed by GitHub
commit 352af583cc
2 changed files with 11 additions and 4 deletions

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'UIAnimatedTextField'
s.version = '0.1.11'
s.version = '0.1.12'
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

@ -194,7 +194,7 @@ open class UIAnimatedTextField: UIView {
}
}
public var selectedDate: Date?
public dynamic var selectedDate: Date?
public var dateFormat: String = Constants.defaultDateFormat
public var doneTitle: String = Constants.done {
didSet {
@ -426,8 +426,7 @@ open class UIAnimatedTextField: UIView {
}
@objc private func datePickerValueChanged(_ datePicker: UIDatePicker) {
selectedDate = datePicker.date
text = datePicker.date.toString(withFormat: dateFormat)
updateText(from: datePicker)
}
private func getDateInputAccessoryView() -> UIView {
@ -451,8 +450,16 @@ open class UIAnimatedTextField: UIView {
return toolbar
}
private func updateText(from datePicker: UIDatePicker) {
selectedDate = datePicker.date
text = datePicker.date.toString(withFormat: dateFormat)
}
@objc private func datePickerDoneAction() {
if let datePicker = textField.inputView as? UIDatePicker {
updateText(from: datePicker)
}
textField.resignFirstResponder()
}