UIFont *theFont = [UIFont systemFontOfSize:14];
NSString *strText = @"这是一段很长的字符串,我们将根据要求的字体大小,来计算实际需要的宽度和高度!";
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithObject:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName]; CGSize size = [strText boundingRectWithSize:CGSizeMake(MAXFLOAT, 0.0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithObject:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName]; CGSize size = [strText boundingRectWithSize:CGSizeMake(100.0, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
typedef NS_ENUM(NSInteger, NSLineBreakMode) {
}NS_ENUM_AVAILABLE_IOS(6_0);
原文:http://blog.csdn.net/u010130947/article/details/42552179