【问题标题】:Obscure a UITextField password隐藏 UITextField 密码
【发布时间】:2011-09-28 13:26:50
【问题描述】:

我正在做一个登录页面。我有 UITextField 作为密码。

显然,我不希望看到密码;相反,我希望在输入时显示圆圈。 你如何设置这个字段?

【问题讨论】:

    标签: ios swift iphone security ipad


    【解决方案1】:

    请设置您的 UItextField 属性安全..

    试试这个..

    textFieldSecure.secureTextEntry = true
    

    textFieldSecure 是你的 UITextField...

    【讨论】:

      【解决方案2】:

      可以为隐藏 UITextField 密码执行此操作:

      代码

      目标-C:

      textField.secureTextEntry = YES;
      

      斯威夫特:

      textField.isSecureTextEntry = true 
      

      【讨论】:

        【解决方案3】:

        在 Interface Builder 中选中“安全文本输入”复选框

        在代码集中:

        目标-C:

        yourTextField.secureTextEntry = YES;
        

        斯威夫特:

        yourTextField.secureTextEntry = true
        

        【讨论】:

          【解决方案4】:

          secureTextEntry 属性设置为YES

          【讨论】:

            【解决方案5】:

            打开 Xib 文件并打开密码文本字段的检查器并勾选安全属性。

            【讨论】:

              【解决方案6】:

              对于 Swift 3.0:

              txtpassword.isSecureTextEntry = true
              

              【讨论】:

              • 你为什么只是重复前面的答案
              • 你在哪里看到答案。
              【解决方案7】:

              在 Swift 3.0 或更高版本中

              passwordTextField.isSecureTextEntry = true
              

              【讨论】:

                【解决方案8】:

                只需选中故事板上的 Secure Text Entry 复选框

                【讨论】:

                • 有没有办法可以隐藏要显示的字符?我根本不想看到这个角色。
                • @ManinderSingh 当然,但这需要一些开箱即用的思考。我能想到的想法是使用文本字段委托方法来拦截所有输入。之后,对任何截获的字符返回 false 并自己构造字符串。看看这个委托方法textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String)
                【解决方案9】:
                txt_Password = new UITextField {
                  Frame = new RectangleF (20,40,180,31),
                  BorderStyle = UITextBorderStyle.Bezel,
                  TextColor = UIColor.Black,
                  SecureTextEntry = true,
                  Font = UIFont.SystemFontOfSize (17f),
                  Placeholder = "Enter Password",
                  BackgroundColor = UIColor.White,
                  AutocorrectionType = UITextAutocorrectionType.No,
                  KeyboardType = UIKeyboardType.Default,
                  ReturnKeyType = UIReturnKeyType.Done,
                  ClearButtonMode = UITextFieldViewMode.WhileEditing,
                };
                

                secureTextEntry 设置为真。

                【讨论】:

                  猜你喜欢
                  • 1970-01-01
                  • 1970-01-01
                  • 2021-05-20
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  • 2013-12-20
                  • 2014-08-10
                  • 2016-01-24
                  相关资源
                  最近更新 更多