How to toggle a UITextField secure text entry (hide password) in Swift?

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.secureTextEntry = false
    } else {
        passwordTF.secureTextEntry = true
    }
    iconClick = !iconClick
}

hope its helpful

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)