替换电话号码中间4位为-号

来源:互联网 发布:mysql查看用户名密码 编辑:程序博客网 时间:2024/05/02 00:43
//电话号码
    UILabel*telLabel = [[UILabelalloc] initWithFrame:CGRectMake(10, yy+30,200,20)];
    telLabel.textColor= [UIColor grayColor];
    telLabel.text= @"13793333281";
    //字符串的截取
    NSString*string = [telLabel.textsubstringWithRange:NSMakeRange(4,4)];
    //字符串的替换
    telLabel.text= [telLabel.text stringByReplacingOccurrencesOfString:string withString:@"----"];
    [self.viewaddSubview:telLabel];

0 0
原创粉丝点击