如何将我的UITableViewCell的标签设置为“SecureText”?UITableViewCell中的SecureText(文本标签)
[cell.textLabel setText:@"passwordNotShown"];
如何将我的UITableViewCell的标签设置为“SecureText”?UITableViewCell中的SecureText(文本标签)
[cell.textLabel setText:@"passwordNotShown"];
您可以使用一个类别:
@interface UILabel (SecureText)
@property (nonatomic, retain) NSString *secureText;
@end
@implementation UILabel (SecureText)
- (void)setSecureText:(NSString *)newText {
NSMutableString *securedMutableText = [NSMutableString new];
for (int i = 0; i < [newText length]; i++) {
[securedMutableText appendString:@"*"];
}
self.text = securedMutableText;
}
- (NSString *)secureText {
return self.text;
}
@end
,然后用它是这样的:
[cell.textLabel setSecureText:@"passwordNotShown"];
UILabel
没有一个安全的属性,你就必须创建一个不可编辑UITextField
定制的小区,其安全特性集。
UILabel没有“安全条目” 如何将掩码字符串设置为标签文本?
NSString *secretText = @"sekert";
NSMutableString *masked = [[NSMutableString alloc] init];
for (int i=0; i < [secretText count] ; i++)
[masked appendString:@"*"]; //
cell.textLabel.text = masked;
[masked release];
非常聪明的主意。 – 2010-06-08 21:28:39
谢谢!这工作得很好:-) 有没有办法使用iPhone“子弹”而不是“*”? – jgray 2010-06-09 07:31:53
我相信子弹是一个普通人物。你只需要知道它的价值。尝试搜索互联网。我找到了这个:http://www.fileformat.info/info/unicode/char/2022/index.htm。 – 2010-06-09 08:12:18