如何将句子分成框/框 - 逐字逐句?

时间:2011-12-07 06:42:42

标签: frame

我试过像

这样的东西
//Putting the sentence into array

NSString *list = (@"A book costs £50.,  Ken has saved £45.,  How much more does he need to save to buy the book?");
 NSArray *listItems = [list componentsSeparatedByString:@", "];

但结果不是我想要的。我希望每个框架都包含一个单词。例如[A] [书] [费用] ......等

    // to create a frame

    CGRect frame= CGRectMake(50, 60, 50, 50);
    comp *newBox = [[comp alloc] initWithFrame:frame ];
    [self.view addSubview:newBox]; 
    newBox.backgroundColor=[UIColor blueColor]
    This frame work fine, i just need to put the word in to each frame

1 个答案:

答案 0 :(得分:0)

试试这个

NSString *list = (@"A book costs £50.  Ken has saved £45.  How much more does he need to save to buy the book?");
NSArray *listItems = [list componentsSeparatedByString:@" "];