ios YYLabel 计算富文本高度

- (CGFloat)getLableHeight:(NSString *)message yyLabel:(YYLabel *)lable{
    
    NSMutableAttributedString  *introText = [[NSMutableAttributedString  alloc] initWithString:message];
    introText.yy_firstLineHeadIndent = 17 *2;
    introText.yy_lineSpacing = 15;
    introText.yy_minimumLineHeight = 15.0f;
    introText.yy_font = kCustemPFRFont(17);
    introText.yy_color = kCustemColor(kMainTitleColor);
    lable.attributedText = introText;
      CGSize introSize = CGSizeMake(lable.frame.size.width, CGFLOAT_MAX);
    YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:introSize text:introText];
    lable.textLayout = layout;
    CGFloat introHeight = layout.textBoundingSize.height;
      return introHeight;
}

你可能感兴趣的:(ios YYLabel 计算富文本高度)