调整Lable字体行间距

来源:互联网 发布:程序员好学吗 编辑:程序博客网 时间:2024/06/06 03:17
/**
   
调整label.text字体间距
 */

- (
void)changeHeightOfLabelLineWithContentLabel:(UILabel*)contentLabel
{
   
NSMutableAttributedString*attributedString = [[NSMutableAttributedStringalloc]initWithString:contentLabel.text];
   
   
NSMutableParagraphStyle*paragraphStyle = [[NSMutableParagraphStylealloc]init];
   
    [paragraphStyle
setLineSpacing:5];
   
    [attributedString
addAttribute:NSParagraphStyleAttributeNamevalue:paragraphStylerange:NSMakeRange(0, contentLabel.text.length)];
   
    contentLabel.
attributedText= attributedString;
   
   
//调节高度
   
   
CGSize size = CGSizeMake(contentLabel.frame.size.width,500000);
   
    [contentLabel
sizeThatFits:size];
}
0 0
原创粉丝点击