你没有得到 UILabel 中特定单词的框架,你只得到 UILabel 框架,你把字符串分成单词,像这样
NSArray *stringArray = [originalString componentsSeparatedByString:@" "];
为每个 UILabel 添加 UILabel 和文本和框架
int x=0;
int y=0;
for(int i=0;i<stringArray.count;i++)
{
CGSize size =[[stringArray objectAtIndex:i] sizeWithFont:[UIFont fontWithName:@"ChaparralPro-Bold" size:fontSize ]];
UILabel *label=[[UILabel alloc]init];
if(x+size.width >320)
{
y=y+size.height;
x=0;
}
label.frame = CGRectMake(x,y,size.width,size.height);
x=x+size.width;
label.text=[wordsArray objectAtIndex:i];
label.textColor=UIColorFromRGB(0x3a5670);
label.font=[UIFont fontWithName:@"ChaparralPro-Bold" size:fontSize];
label.backgroundColor=[UIColor clearColor];
[self.view addSubview:label];
[label release];
}