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

前端 未结 24 2346
时光取名叫无心
时光取名叫无心 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 02:57

    Use UITextFiled rightView to show toggle button

     var rightButton  = UIButton(type: .custom)
     rightButton.frame = CGRect(x:0, y:0, width:30, height:30)
     yourtextfield.rightViewMode = .always
     yourtextfield.rightView = rightButton
    

提交回复
热议问题