iOS之label根据文字多少和尺寸确定其高度

 UILabel * label = [[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 195, 195)] autorelease];

        label.text = htmlStr;

        label.textColor = [UIColor colorWithRed:60/225.0 green:60/255.0 blue:60/255.0 alpha:1.0];

        [label setFont:[UIFont systemFontOfSize:15.0]];

        label.textAlignment = NSTextAlignmentLeft;

        label.numberOfLines = 0;

        CGSize size = [htmlStr sizeWithFont:label.font constrainedToSize:CGSizeMake(label.frame.size.width, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];

        label.frame = CGRectMake(0, 0, labelSize.width + 23, size.height+5);

原文地址:https://www.cnblogs.com/pangbin/p/5227357.html