Commit 3130a55c by Daniel Dahan

issue-856: fixed issue where TextField.placeholderAnimation = .hidden was not…

issue-856: fixed issue where TextField.placeholderAnimation = .hidden was not correct being displayed when text was set to nil. Closes #856
parent 7d45b943
Pod::Spec.new do |s|
s.name = 'Material'
s.version = '2.10.1'
s.version = '2.10.2'
s.license = 'BSD-3-Clause'
s.summary = 'A Material Design library for creating beautiful applications.'
s.homepage = 'http://materialswift.com'
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.10.1</string>
<string>2.10.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -216,11 +216,11 @@ fileprivate extension SearchBar {
textField.font = RobotoFont.regular(with: 17)
textField.backgroundColor = Color.clear
textField.clearButtonMode = .whileEditing
textField.addTarget(self, action: #selector(handleEditingChanged(textField:)), for: .editingChanged)
tintColor = placeholderColor
textColor = Color.darkText.primary
placeholder = "Search"
contentView.addSubview(textField)
textField.addTarget(self, action: #selector(handleEditingChanged(textField:)), for: .editingChanged)
}
/// Prepares the clearButton.
......
......@@ -76,7 +76,12 @@ open class TextField: UITextField {
/// Set the placeholder animation value.
open var placeholderAnimation = TextFieldPlaceholderAnimation.default {
didSet {
placeholderLabel.isHidden = .hidden == placeholderAnimation && !isEmpty
guard isEditing else {
placeholderLabel.isHidden = !isEmpty && .hidden == placeholderAnimation
return
}
placeholderLabel.isHidden = .hidden == placeholderAnimation
}
}
......@@ -85,6 +90,12 @@ open class TextField: UITextField {
return 0 == text?.utf16.count
}
open override var text: String? {
didSet {
placeholderAnimation = { placeholderAnimation }()
}
}
open override var leftView: UIView? {
didSet {
prepareLeftView()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment