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 check mark the "secure text entry" box in the attributes inspector but how to do it so it toggles whenever the icon is pressed?
Use this code,
iconClick is bool variable, or you need other condition check it,
var iconClick = true
eye Action method:
@IBAction func iconAction(sender: AnyObject) {
if iconClick {
passwordTF.isSecureTextEntry = false
} else {
passwordTF.isSecureTextEntry = true
}
iconClick = !iconClick
}
hope its helpful