ios-包装了一个富文本类.zip
//获取url数组 NSArray *urlArr = [SHMatching urlArrWithString:str]; //电话 NSArray *phoneArr = [SHMatching phoneNumArrWithString:str]; //邮箱 NSArray *emailArr = [SHMatching emailStringArrWithString:str]; NSAttributedString *att_str1 = [[NSAttributedString alloc]initWithString:str]; //识别url NSAttributedString *attstr = [SHAttributedString attributedStringWithString:str andUrlStringName:nil line:NO]; //指定url名称 attstr = [SHAttributedString attributedStringWithAttString:att_str1 andUrlStringName:@"百度" urlStr:@"http://www.baidu.com" line:YES]; attstr = [SHAttributedString attributedStringWithAttString:attstr andUrlStringName:@"微博" urlStr:@"http://www.weibo.com"line:YES]; //改变指定位置文字颜色 NSAttributedString *att_str = [SHAttributedString attributedStringWithAttributedString:attstr andColor:[UIColor blackColor] font:[UIFont fontWithName:@"Arial" size:20] range:NSMakeRange(0, attstr.length)]; //插入图片 att_str = [SHAttributedString attributedStringWithAttributedString:att_str insertImage:[UIImage imageNamed:@"compose_emoticonbutton_background_highlighted@2x"] atIndex:3]; //识别电话 att_str = [SHAttributedString attributedPhoneStringWithString:att_str insertImage:[UIImage imageNamed:@"chatBar_colorMore_audioCallSelected@2x"] orPhoneNameString:nil isCall:NO]; //识别邮箱 att_str = [SHAttributedString attributedEmailStringWithString:att_str insertImage:[UIImage imageNamed:@"compose_emoticonbutton_background_highlighted@2x"] orEmailNameString:@"邮箱"]; //计算size CGSize size = [SHAttributedString attributedStringSizeWithAttString:att_str preinstallSize:CGSizeMake(self.view.frame.size.width-20, MAXFLOAT)]; self.myTextView.attributedText = att_str;
- 1
- 粉丝: 409
- 资源: 1万+
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- DMN2005K-7-VB一款N-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- 度目视频分析盒子B1 HTTP 开发文档
- DMN100-7-F-VB一款SOT23封装N-Channel场效应MOS管
- 清华大学计算机科学与技术专业课程介绍
- stm32cubemx入门教程.pdf
- DMG9933USD-VB一款SOP8封装2个P-Channel场效应MOS管
- 2021112501-齐敬涵.ipynb
- DMG6968UQ-7-VB一款SOT23封装N-Channel场效应MOS管
- 资源名称资源名称资源名称
- DMG4407SSS-13-VB一款P-Channel沟道SOP8的MOSFET晶体管参数介绍与应用说明