2010-04-20 65 views
0

我希望到文本輸入掩碼,UITextFiled爲:掩蓋密碼輸入到UITexfield

"ABCDE" to 
"*****" 
下面

是我沒有的功能代碼

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string 
{ 
    int l=[textField.text length]; 
    range=NSMakeRange(1, l); 
    string=[[[NSString alloc]initWithString:@"*"] autorelease]; 
    return YES; 
} 

回答

1

UITextField支持密碼輸入本身,只是設置其secureTextEntry財產改爲YES。 (詳情請參閱UITextInputTraits協議文檔)