CGSize labelSize=[self.myDetailLabel.text boundingRectWithSize:CGSizeMake([UIScreen mainScreen].bounds.size.width-20, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: self.myDetailLabel.font} context:nil].size;
self.myDetailLabel.numberOfLines=0;
self.myDetailLabel.textColor=[UIColor lightGrayColor];
//不要忘了设置font
self.myDetailLabel.font=[UIFont fontWithName:@"Hiragino Sans GB" size:14];
self.myDetailLabel.frame=CGRectMake(10,self.myTextField.frame.origin.y+self.myTextField.frame.size.height+5,labelSize.width,labelSize.height);
原文地址:http://blog.csdn.net/darongzi1314/article/details/43452995