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?
Or you can do it using code: Identifies whether the text object should hide the text being entered. This property is set to false by default. Setting this property to true creates a password-style text object, which hides the text being entered.
How do you make a text field Uneditable in Swift? Within code: textfield. enable = false.
A Boolean value that indicates whether a text object disables copying, and in some cases, prevents recording/broadcasting and also hides the text.
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 == true) { passwordTF.secureTextEntry = false } else { passwordTF.secureTextEntry = true } iconClick = !iconClick }
hope its helpful
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With