设为首页 加入收藏

TOP

【代码笔记】iOS-替换电话号码中间4位为-号
2017-10-13 10:23:48 】 浏览:8813
Tags:代码 笔记 iOS- 替换 电话号码 中间 4位为

一,效果图。

二,代码。

RootViewController.m

复制代码
- (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];
}
复制代码

 

 

 
 
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇打印frame 下一篇算法

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目