// 旧方法:
NSString * str = @"我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个";
CGSize labSize = [str sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(200, 1000) lineBreakMode:NSLineBreakByCharWrapping];
UILabel * label2 = [[UILabel alloc] initWithFrame:CGRectMake(0,64, 200, 20)];
label2.font = [UIFont systemFontOfSize:17];
label2.lineBreakMode = NSLineBreakByCharWrapping;
label2.numberOfLines = 0;
label2.textColor = [UIColor redColor];
label2.text = str;
label2.frame = CGRectMake(0,64,labSize.width,labSize.height);
[self.view addSubview:label2];
// 新方法:
UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0,64, 200, 20)];
label.font = [UIFont systemFontOfSize:17];
label.lineBreakMode = NSLineBreakByCharWrapping;
label.numberOfLines = 0;
label.textColor = [UIColor redColor];
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping;
NSDictionary * attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:17],NSParagraphStyleAttributeName : paragraphStyle};
NSString * str = @"我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个,我是亿万富我那个";
CGRect rect =[str boundingRectWithSize:CGSizeMake(200, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:attributes context:nil];
label.frame = CGRectMake(0,64,rect.size.width, rect.size.height);
label.text = str;
NSLog(@"width:%f height:%f",rect.size.width,rect.size.height);
[self.view addSubview:label];