NSString *str=@"// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the gamehhhhhhhhhhh看见了刚刚好hi了;会考虑换回来来了;了;两节课;绿林豪客;哈伦裤;哈伦裤;哈伦裤;好可怜;哈伦裤;哈伦裤;哈伦裤;哈伦裤;哈伦裤;好可怜;哈伦裤;好vfGfgigfigqiFGIwgggoGOGLFGGFKVMBXZVGHSDFGLAHOFHYAWOYFOAWHOGFAWOYEFOWOFOWHFOAEW可怜;.";
//获取文字的rect
NSDictionary *dact=@{NSFontAttributeName:[UIFont systemFontOfSize:17]};//17代表字体大小,默认17
//
CGRect textRect=[str boundingRectWithSize:CGSizeMake(320, 1000) options: NSStringDrawingUsesLineFragmentOrigin attributes:dact context:nil];
//NSLog(@"%@",NSStringFromCGRect(textRect));
UILabel *label=[[UILabel alloc]init];
label.frame=CGRectMake(0,22, 320, 20);
//label.frame.size.height=textRect.size.height;//frame中的值不可以单独修改(不可以这样)
CGRect tempRect=label.frame;
//单独修改高之后,再用tempRect给frame赋值
tempRect.size.height=textRect.size.height;//用上面计算好的高付给需要修改的高
label.frame=tempRect;
label.text=str;
//label.backgroundColor=[UIColor redColor];
label.numberOfLines=0;
[self.window addSubview:label];