Guest User

Untitled

a guest
Jul 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  2. {
  3. textField.text = [textField.text stringByReplacingCharactersInRange:range withString:string];
  4.  
  5. NSString *pass = password;
  6. pass = [pass stringByReplacingCharactersInRange:range withString:string];
  7.  
  8. [password release];
  9. password = nil;
  10.  
  11. password = [[NSString stringWithString:pass] retain];
  12.  
  13. [self hideTextInTextFieldExceptOne:string];
  14.  
  15. [self performSelector:@selector(hideTextInTextField) withObject:self afterDelay:1.0];
  16.  
  17. return NO;
  18. }
  19.  
  20. - (void)hideTextInTextFieldExceptOne:(NSString *)string
  21. {
  22. int lenght = [passwordTextField.text length];
  23.  
  24. for (int i = 0; i < lenght-1; i++)
  25. {
  26. NSRange range = NSMakeRange(i, 1);
  27. passwordTextField.text = [passwordTextField.text stringByReplacingCharactersInRange:range withString:@"*"];
  28. }
  29. }
  30.  
  31. - (void)hideTextInTextField
  32. {
  33. NSUInteger lenght = [passwordTextField.text length];
  34. passwordTextField.text = @"";
  35.  
  36. for (int i = 0; i < lenght; i++)
  37. {
  38. passwordTextField.text = [passwordTextField.text stringByAppendingString:@"*"];
  39. }
  40. }
Add Comment
Please, Sign In to add comment