一、比如12345678900----------->想显示成123*****900
1、使用
NSString *name=@"12345678900";
NSString *phoneStr= [self replaceStringWithAsterisk:name startLocation:3 lenght:name.length -6];
2、字符串、开始位置、结束位置
-(NSString *)replaceStringWithAsterisk:(NSString *)originalStr startLocation:(NSInteger)startLocation lenght:(NSInteger)lenght
{
NSString *newStr = originalStr;
for (int i = 0; i < lenght; i++) {
NSRange range = NSMakeRange(startLocation, 1);
newStr = [newStr stringByReplacingCharactersInRange:range withString:@"*"];
startLocation ++;
}
return newStr;
}