Commit 1c3541f2 by Orkhan Alikhanov

Added updatePlaceholderVisibility

parent ad547b74
...@@ -76,12 +76,7 @@ open class TextField: UITextField { ...@@ -76,12 +76,7 @@ open class TextField: UITextField {
/// Set the placeholder animation value. /// Set the placeholder animation value.
open var placeholderAnimation = TextFieldPlaceholderAnimation.default { open var placeholderAnimation = TextFieldPlaceholderAnimation.default {
didSet { didSet {
guard isEditing else { updatePlaceholderVisibility()
placeholderLabel.isHidden = !isEmpty && .hidden == placeholderAnimation
return
}
placeholderLabel.isHidden = .hidden == placeholderAnimation
} }
} }
...@@ -92,7 +87,7 @@ open class TextField: UITextField { ...@@ -92,7 +87,7 @@ open class TextField: UITextField {
open override var text: String? { open override var text: String? {
didSet { didSet {
placeholderAnimation = { placeholderAnimation }() updatePlaceholderVisibility()
} }
} }
...@@ -523,6 +518,16 @@ fileprivate extension TextField { ...@@ -523,6 +518,16 @@ fileprivate extension TextField {
placeholderLabel.textColor = isEditing ? placeholderActiveColor : placeholderNormalColor placeholderLabel.textColor = isEditing ? placeholderActiveColor : placeholderNormalColor
} }
/// Updates the placeholder visibility.
func updatePlaceholderVisibility() {
guard isEditing else {
placeholderLabel.isHidden = !isEmpty && .hidden == placeholderAnimation
return
}
placeholderLabel.isHidden = .hidden == placeholderAnimation
}
/// Updates the dividerColor. /// Updates the dividerColor.
func updateDividerColor() { func updateDividerColor() {
dividerColor = isEditing ? dividerActiveColor : dividerNormalColor dividerColor = isEditing ? dividerActiveColor : dividerNormalColor
......
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