富文本计算方法
// 富文本格式
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
paraStyle.lineSpacing = 1.0;
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithData:[introduceText dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
[attributedString setAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14*KWIDTH_IPHONE6_SCALE], NSParagraphStyleAttributeName:paraStyle} range:NSMakeRange(0, attributedString.length)];
[attributedString addAttribute:NSBaselineOffsetAttributeName value:[NSNumber numberWithFloat:5.0] range:NSMakeRange(0, attributedString.length)];
//富文本高度计算方法
CGSize lblSize = [attributedString boundingRectWithSize:CGSizeMake(labelSize, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin context:nil].size;
double describeheight = ceil(lblSize.height ) ;//为防止文字显示不全,采用向上取整函数获取最终文本高度
普通文本计算方法
CGSize lblSize = [model.describestring boundingRectWithSize:CGSizeMake(SCREEN_WIDTH-44, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14*KWIDTH_IPHONE6_SCALE]} context:nil].size;
double describeheight = ceil(lblSize.height ) ;
HTML文本若用普通文本计算高度的方法(第二种方法)计算,会导致计算高度偏小,文本显示不全