根据label.text 宽度和字号计算高度
CGRect rect = [title boundingRectWithSize:CGSizeMake(Width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:font]} context:nil];
根据label.text 高度和字号计算宽度
CGRect rect = [title boundingRectWithSize:CGSizeMake(MAXFLOAT, Height) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:font]} context:nil];
根据label.text 字号计算行高
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:font];
label.numberOfLines = 1;
label.text = title;
[label sizeToFit];
CGFloat rowHeight = label.frame.size.height;
根据高度和行高计算行数
NSInteger row = rect.size.height / rowHeight;