记得以前用过,但是现在又用到,还是写不出来,特此,记录一下
- (CGFloat)textLableHeightWithString:(NSString *)str Width:(CGFloat)width { CGSize size = CGSizeMake(width, MAXFLOAT); // 此处,需要注意 字体的调整,否则,高度不准确 CGSize expectedLabelSize = [str sizeWithFont:kContentFontSmall constrainedToSize:size lineBreakMode:NSLineBreakByTruncatingMiddle]; // 限制最小行的高度。低于某个值,返回一个值 return expectedLabelSize.height>kCellHeight?expectedLabelSize.height-8:kCellHeight; }
以上可以用来救急,因为在IOS7之后,这个方法已经抛弃了。