Label自动换行步骤:
1、获取显示内容,字符串。通过字符串获取cgsize,最后将heigh赋值给label的frame.size.height. 最后记得设置label 的numoflines属性为 0
以下方法适用于ios7以上
NSString *label_str = @"abc";
NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:12.0]};
CGSize retSize = [label_str boundingRectWithSize:CGSizeMake(ScreenWidth - kHViewWidth, CGFLOAT_MAX)
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
attributes:attribute
context:nil].size;
_label.frame.size.height=retSize.height;