如何将UITableViewCell的标签设置为“SecureText”?
[cell.textLabel setText:@"passwordNotShown"];
答案 0 :(得分:1)
您可以使用类别:
@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"];
答案 1 :(得分:0)
UILabel
没有安全属性,您必须使用设置了安全属性的不可编辑UITextField
创建自定义单元格。
答案 2 :(得分:0)
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];