-5

英語でごめんなさい。

単語を文字で区切って表示したい。「chars」配列に単一の文字を含むさまざまな文字列があります。私はこれを試しました:

int x = 20;
int y = 20;
int screenx = self.view.bounds.size.width - 14;
for (NSString *string in chars){
    for (int i=0; i<messageLength; i++) {
        UILabel *display;
        display.text = [chars objectAtIndex:i];
        display.frame = CGRectMake(x, y, 14, 22);
        display.textColor = [UIColor whiteColor];
        x = x + 14;
        if (x >= screenx){
            x = 20;
            y = y + 20;
        }

    }
}
4

1 に答える 1

0

実際にラベルを作成して、ビューに配置する必要があります。

UILabel *display = [[UILabel alloc] init];
display.text = [chars objectAtIndex:i];
display.frame = CGRectMake(x, y, 14, 22);
display.textColor = [UIColor whiteColor];
[self.view addSubView:display];
于 2013-01-07T18:42:55.873 に答える