【问题标题】:Reveal Passcode dots using Swift使用 Swift 显示密码点
【发布时间】:2015-11-04 23:25:30
【问题描述】:

如何快速显示密码点,以便用户可以通过单击按钮查看密码。 谢谢 类型

【问题讨论】:

    标签: swift ios8 swift2 ios9


    【解决方案1】:

    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)
        }
    }
    

    【讨论】:

      【解决方案2】:

      stackoverflow 提供了一个有效的搜索引擎,但无论如何你就是答案。

      做同样的事情,但使用false 而不是true

      Obscure a UITextField password

      顺便说一句,确保用户知道他在显示安全文本时做了什么。

      【讨论】:

        猜你喜欢
        • 2012-03-07
        • 1970-01-01
        • 1970-01-01
        • 2021-04-17
        • 2012-03-14
        • 2017-08-22
        • 1970-01-01
        • 2011-04-29
        • 2023-03-25
        相关资源
        最近更新 更多