美文网首页
iOS iUITextField的secureTextEntry

iOS iUITextField的secureTextEntry

作者: 翻滚的炒勺2013 | 来源:发表于2018-07-23 13:45 被阅读62次

1.切换明密文状态,最后在密文状态,再次编辑,输入任意字符,内容清空;
2.其他textField获取焦点,再切回来(密文状态),内容清空

- (IBAction)eyeBtnClick:(UIButton *)sender {
    sender.selected = !sender.selected;
    self.pswTextField.secureTextEntry = !sender.selected;
    NSString *text = self.pswTextField.text;
    self.pswTextField.text = @" ";
    self.pswTextField.text = text;
    if (self.pswTextField.secureTextEntry) {
        [self.pswTextField insertText:self.pswTextField.text];
        
    }
    
}
- (void)textFieldDidBeginEditing:(UITextField *)textField {
    if (textField == self.pswTextField) {
        if (textField.secureTextEntry) {
         [textField insertText:self.pswTextField.text];
        }
    }
}

相关文章

网友评论

      本文标题:iOS iUITextField的secureTextEntry

      本文链接:https://www.haomeiwen.com/subject/datjmftx.html