Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
274 views
in Technique[技术] by (71.8m points)

ios - How do you obscure text in a password field in an iPhone Application?

I have a password field in my application (UITextField). When user enters text in the field, I want it to display * instead of the text they entered.

I have tried using the UIControlEventEditingDidEnd of UITextField but it only shows one * at the end when editing but I want it to display the *s as soon as any text is entered, like in any online email password field. How can I get the desired behavior?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I don't really understand your question, but I'm guessing you want a UITextField which displays dots for the characters, which every password field on the iPhone does. For this, you want to set the secureTextEntry property of that UITextField (UITextField has such a property because it conforms to the UITextInputTraits protocol) to YES:

textfield.secureTextEntry = YES;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...