使用Swift显示密码点
答
*提供了一个工作的搜索引擎,但无论如何,在这里你是答案。
做相同,但与false
代替true
Obscure a UITextField password
顺便说一句,确保用户知道他做什么时,揭示了安全的文本。
答
TextField有一个名为secureTextEntry的属性。所有你需要的是一个出口连接到您的文本框和切换secureTextEntry:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var passwordField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
passwordField.secureTextEntry = true
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func showHide(sender: UIButton) {
passwordField.secureTextEntry = !passwordField.secureTextEntry
sender.setTitle({passwordField.secureTextEntry ? "Show":"Hide"}(), forState: .Normal)
}
}
https://www.dropbox.com/s/3gyh7cd6lweo13n/passwordInput.zip?dl=0 –