YYKit 学习笔记之 YYLabel
使用Cocoapods安装YYKit
YYKit GitHub传送门:https://github.com/ibireme/YYKit
一.打开工程的 Podfile文件
二.在Podfile文件中添加pod ‘YYKit’, ‘~> 1.0.9’
三.终端进入工程目录,执行pod install
YYKit 添加成功
添加头文件
#import <YYKit/YYKit.h>
NSString *textStr = @"The YYLabel class implements a read-only text view,这是删除样式~~这是下划线样式~~这是带边框样式,这是带阴影样式,点击交互事件,添加点击事件,分割分割分割";
YYLabel * label = [[YYLabel alloc] initWithFrame:CGRectZero];
label.backgroundColor = [UIColor grayColor];
label.numberOfLines = 0;
label.textVerticalAlignment = YYTextVerticalAlignmentTop;//垂直属性,上 下 或居中显示
//富文本属性
NSMutableAttributedString * attriStr = [[NSMutableAttributedString alloc] initWithString:textStr];
//设置行间距
attriStr.lineSpacing = 10;
attriStr.font = [UIFont systemFontOfSize:20];
//富文本属性
NSRange range =[textStr rangeOfString:@"The YYLabel class implements a read-only text view"];
[attriStr setFont:[UIFont boldSystemFontOfSize:30] range:range];
//删除样式
NSRange range2 =[textStr rangeOfString:@"这是删除样式" options:NSCaseInsensitiveSearch];
YYTextDecoration *deletDecoration = [YYTextDecoration decorationWithStyle:YYTextLineStyleSingle width:@(1) color:[UIColor redColor]];
[attriStr setT