//这个frame是初设的,没关系,后面还会重新设置其size。
NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:20],};
NSString *str = @"这里是lab里的内容";
CGSize textSize = [str boundingRectWithSize:CGSizeMake(100, 100)
options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;;
[label setFrame:CGRectMake(100, 100, textSize.width, textSize.height)];
label.textColor = [UIColor greenColor];
label.text = str;
[self.view addSubview:label];
转自:http://my.oschina.net/u/1440723/blog/476826