Commit 0ea63991 by Orkhan Alikhanov

Fixed changing isSecureTextEntry does not change visibility icon

parent 1eafbc83
...@@ -204,6 +204,12 @@ open class TextField: UITextField { ...@@ -204,6 +204,12 @@ open class TextField: UITextField {
} }
} }
open override var isSecureTextEntry: Bool {
didSet {
visibilityIconButton?.image = visibilityIcon
}
}
/// The placeholder UILabel. /// The placeholder UILabel.
@IBInspectable @IBInspectable
open let placeholderLabel = UILabel() open let placeholderLabel = UILabel()
...@@ -653,8 +659,6 @@ fileprivate extension TextField { ...@@ -653,8 +659,6 @@ fileprivate extension TextField {
/// Handles the visibilityIconButton TouchUpInside event. /// Handles the visibilityIconButton TouchUpInside event.
@objc @objc
func handleVisibilityIconButton() { func handleVisibilityIconButton() {
isSecureTextEntry = !isSecureTextEntry
/// Workaround: Reassign text to reset cursor /// Workaround: Reassign text to reset cursor
/// This is a known issue with UITextField /// This is a known issue with UITextField
/// Source: https://stackoverflow.com/questions/14220187/uitextfield-has-trailing-whitespace-after-securetextentry-toggle /// Source: https://stackoverflow.com/questions/14220187/uitextfield-has-trailing-whitespace-after-securetextentry-toggle
...@@ -671,11 +675,7 @@ fileprivate extension TextField { ...@@ -671,11 +675,7 @@ fileprivate extension TextField {
return return
} }
guard let v = self.visibilityIconButton else { self.isSecureTextEntry = !self.isSecureTextEntry
return
}
v.image = self.visibilityIcon
}) })
} }
} }
......
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