码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-06-29 14:34:20      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:

 

代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    //替换电话号码中间4位为-
    [self addView];
}
#pragma -mark -functions
-(void)addView
{
    //电话号码
    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];

}

 

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

标签:

原文地址:http://www.cnblogs.com/yang-guang-girl/p/4607301.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!