代码库> 图文混排> 包装了一个富文本类
包装了一个富文本类
关注
上传者:更多_ 分类:图文混排(Text & Graphics)
查看次数:3121 下载次数:686
上传时间:2016-06-13 大小:6 B
//获取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;
收藏
我来说两句
发表评论
您还没有登录!请登录注册
所有评论(0


综合评论
提示
sina weixin mail 回到顶部