I currently have a UITextfield
with an eye icon in it that when pressed is supposed to toggle the secure text entry on and off.
I know you can che
Hope this is simpler solution rather than creating a BOOL object globally.
@IBAction func passwordToggleButton(sender: UIButton) {
let isSecureTextEntry = passwordTextField.isSecureTextEntry
passwordTextField.isSecureTextEntry = isSecureTextEntry ? false : true
if isSecureTextEntry {
visibilityButton.setImage(UIImage(named: "visibility"), for: .normal)
} else {
visibilityButton.setImage(UIImage(named: "visibility_off"), for: .normal)
}
}