UILabel 设置行间距

时间:2020-12-20 06:05:41
  UILabel *label1 = [[UILabel alloc]initWithFrame:frame];
label1.numberOfLines = 0;
[self.view addSubview:label1];
NSString *testString = @"欢迎您加入*******************";
NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:testString];
NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle1 setLineSpacing:15];
[attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [testString length])];
[label1 setAttributedText:attributedString1];