-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 回答