Label 不定高 行高

Label 不定高 行高

// 动态计算高度

    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:model.remark];

    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];

    // 调整行间距

    paragraphStyle.lineSpacing = 5.0;

    NSRange range = NSMakeRange(0, model.remark.length);


    [attributedString addAttribute:NSFontAttributeName value:SystemFont(Auto(16)) range:range];

    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:range];


    CGSize size = [attributedString boundingRectWithSize:CGSizeMake(ScreenWidth - Auto(45), MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size;


    CGFloat remarkHeight = size.height + Auto(30);

你可能感兴趣的:(Label 不定高 行高)