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

前端 未结 24 2336
时光取名叫无心
时光取名叫无心 2021-01-30 02:00

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

24条回答
  •  心在旅途
    2021-01-30 03:07

    Here is your answer no need to take any bool var:

    @IBAction func showHideAction(sender: AnyObject) {
    
            if tfPassword.secureTextEntry{
                tfPassword.secureTextEntry = false
    
            }else{
                tfPassword.secureTextEntry = true;
            } 
        }
    

提交回复
热议问题