如何设置UILabel中的字体的间距

时间:2015-06-21 17:12:37   收藏:0   阅读:104

 

 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需要把间距设置大一点 ,只需要把普通的文本转成带有格式的文本就行了 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!