UILabel 本身没有提供调节行间距的接口,但是字符串提供了修改其表示格式的方法,可简单表示如下:
introduce = @"来得及发垃圾发酵了放假啊理解费拉达斯肌肤垃圾的酸辣粉阿拉斯加法拉盛大家发垃圾啊的胜利解放啦放假啦大家费拉达斯家啦";
CGSize maxSize = CGSizeMake(ScreenSize.width-40, 500000); //设置字符串显示的最大区域
NSDictionary * contentAttribute = @{NSFontAttributeName:[UIFont systemFontOfSize:15]};
NSMutableAttributedString * attributeStr = [[NSMutableAttributedString alloc]initWithString:introduce attributes:contentAttribute];
NSMutableParagraphStyle * style = [[NSMutableParagraphStyle alloc]init];
style.lineSpacing = 8; //设置行间距
[attributeStr addAttribute:NSParagraphStyleAttributeName value:style range:NSMakeRange(0, introduce.length)];
CGSize size = [attributeStr boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin context:nil].size;//获取字符内容所占的区域
_introduceLabel.attributedText = attributeStr;
_introduceLabel.frame = CGRectMake(20, 13, ScreenSize.width-40, size.height);