当前位置: 代码迷 >> Iphone >> 轮换电话号码中间4位为-号
  详细解决方案

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

热度:356   发布时间:2016-04-25 05:45:40.0
替换电话号码中间4位为-号

效果图:

代码:

- (void)viewDidLoad{    [super viewDidLoad];    // Do any additional setup after loading the view.        //电话号码    UILabel *telLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 200, 20)];    telLabel.textColor = [UIColor grayColor];    telLabel.text = @"13793333281";    //字符串的截取    NSString *string = [telLabel.text substringWithRange:NSMakeRange(4,4)];    //字符串的替换    telLabel.text = [telLabel.text stringByReplacingOccurrencesOfString:string withString:@"----"];    [self.view addSubview:telLabel];}