Question

The dots iOS7.1 uses for Secure Text Fields are bigger than the previous ones and are pretty ugly.

Can I use a different icon instead of these standard dots? If so, how do I do that?

Was it helpful?

Solution

You can try the following code:

/* don't ever use this PROOF OF CONCEPT CODE for production use */
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{   
if ( self.backing == nil ) self.backing = @"";
static BOOL pasting = false;

if ( !pasting )
{       
    self.backing = [self.backing stringByReplacingCharactersInRange:range withString:string];
    NSLog(@"backing: %@",self.backing);
    if ( [string length] == 0 ) return YES; // early bail out when just deleting chars

    NSString *sec = @"";
    for ( int i=0;i<[string length]; i++ ) sec = [sec stringByAppendingFormat:@"■"];

    pasting = true;
    [[UIPasteboard generalPasteboard] setString:sec];
    [textField paste:self];

    return NO;  
} else {
    pasting = false;
    return YES; 
}       
} 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top