UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(50, 100, 200, 300)];
label.backgroundColor=[UIColor orangeColor];
label.text=@"当时,“0”还没有出现。到了笈多时代(300~500年)才有了“0”,叫“舜若”(shunya),表示方式是一个黑点“●”,后来衍变成“0”。这样,一套完整的数字便产生了。这项劳动创作也对世界文化做出了巨大的贡献。";
label.numberOfLines=0;
[self.view addSubview:label];
//设置行间距
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
paragraphStyle.lineSpacing = 50;
NSDictionary *attributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:14], NSParagraphStyleAttributeName:paragraphStyle};
label.attributedText = [[NSAttributedString alloc]initWithString:label.text attributes:attributes];
//利用SDAutoLayout三方设置行间距
NSString *text = @"attributedString测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试测试:";
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:8];
UIColor *color = [UIColor blackColor];
NSAttributedString *string = [[NSAttributedString alloc] initWithString:text attributes:@{NSForegroundColorAttributeName : color, NSParagraphStyleAttributeName: paragraphStyle}];
UILabel *label = [UILabel new];
[self.view addSubview:label];
label.attributedText = string;
label.sd_layout
.leftSpaceToView(self.v, 10)
.rightSpaceToView(self.view, 10)
.topSpaceToView(self.view, 70)
.autoHeightRatio(0);
// 标注lable的text为attributedString
```label.isAttributedContent = YES;