1.xcode7.0之前
CGSize textMaxSize = CGSizeMake(kScreenWidth - 10 *2, MAXFLOAT);//文字的size
cellHeight += [str sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:textMaxSize].height
2.xcode 7.0之后
CGSize textMaxSize = CGSizeMake(kScreenWidth - 10 *2, MAXFLOAT); //文字的size
cellHeight += [self.title boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName :[UIFont systemFontOfSize:15]} context:nil].size.height;
xib中的设置的文字大小需要和代码中的一致 否则会引起误差
bmLable.lineBreakMode lable中文字的样式
typedef NS_ENUM(NSInteger, NSLineBreakMode) {NSLineBreakByWordWrapping = 0, // Wrap at word boundaries, default
NSLineBreakByCharWrapping, // Wrap at character boundaries
NSLineBreakByClipping, // Simply clip
NSLineBreakByTruncatingHead, // Truncate at head of line: "...wxyz"
NSLineBreakByTruncatingTail, // Truncate at tail of line: "abcd..."
NSLineBreakByTruncatingMiddle // Truncate middle of line: "ab...yz"
} NS_ENUM_AVAILABLE(10_0, 6_0);