美文网首页
用CoreText实现类似微博那样可以点击的Label

用CoreText实现类似微博那样可以点击的Label

作者: 五蕴皆空_ | 来源:发表于2017-04-01 21:16 被阅读43次

JLLabel

用CoreText实现类似微博那样可以点击的文字,自动识别@,#,http(s)等特殊字符串,用法如下:

JLLabel *contentLabel = [[JLLabel alloc] init];
contentLabel.font = [UIFont systemFontOfSize:15.0];
contentLabel.tapCallBack = ^(NSString *string,NSRange range,NSDictionary *info){
            
     NSLog(@"点击的字符串是:%@",string);
     NSLog(@"点击的字符串的范围是:%@",[NSValue valueWithRange:range]);
  
 };
[self.contentView addSubview:contentLabel];
 
效果图

下载点击源代码

相关文章

网友评论

      本文标题:用CoreText实现类似微博那样可以点击的Label

      本文链接:https://www.haomeiwen.com/subject/djlwottx.html