Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
- {
- textField.text = [textField.text stringByReplacingCharactersInRange:range withString:string];
- NSString *pass = password;
- pass = [pass stringByReplacingCharactersInRange:range withString:string];
- [password release];
- password = nil;
- password = [[NSString stringWithString:pass] retain];
- [self hideTextInTextFieldExceptOne:string];
- [self performSelector:@selector(hideTextInTextField) withObject:self afterDelay:1.0];
- return NO;
- }
- - (void)hideTextInTextFieldExceptOne:(NSString *)string
- {
- int lenght = [passwordTextField.text length];
- for (int i = 0; i < lenght-1; i++)
- {
- NSRange range = NSMakeRange(i, 1);
- passwordTextField.text = [passwordTextField.text stringByReplacingCharactersInRange:range withString:@"*"];
- }
- }
- - (void)hideTextInTextField
- {
- NSUInteger lenght = [passwordTextField.text length];
- passwordTextField.text = @"";
- for (int i = 0; i < lenght; i++)
- {
- passwordTextField.text = [passwordTextField.text stringByAppendingString:@"*"];
- }
- }
Add Comment
Please, Sign In to add comment