计算NSMutableAttributedString 高度

NSMutableAttributedString  *attributedString = [[NSMutableAttributedString alloc] initWithString:content];
    
 NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
行间距    
[paragraphStyle1 setLineSpacing:10];

[attributedString addAttribute:NSKernAttributeName value:@10 range:NSMakeRange(0, content.length)];//字间距

字体
[attributedString addAttribute:NSFontAttributeName value:kSYS_FONT(15) range:NSMakeRange(0, content.length)];


[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [content length])];

CGFloat contentHeight = [attributedString boundingRectWithSize:CGSizeMake(kSCREEN_WIDTH-20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size.height+40;

你可能感兴趣的:(计算NSMutableAttributedString 高度)