如何设置UILabel中的字体的间距
1 cell.teacherDescriptionLabel.text = content; 2 cell.teacherDescriptionLabel.textAlignment = NSTextAlignmentJustified; 3 NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:content]; 4 NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; 5 paragraphStyle.alignment = NSTextAlignmentJustified;//设置对齐方式 6 paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping; 7 [paragraphStyle setLineSpacing:7];//调整行间距 8 9 [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [content length])]; 10 cell.teacherDescriptionLabel.attributedText = attributedString;
我们假定cell中的一个UILabel需要把间距设置大一点 ,只需要把普通的文本转成带有格式的文本就行了