我試圖按照每次單擊UIbutton時句子的單詞順序將單詞的單詞初始化爲UIlabels。將存儲在字符串中的句子的單詞初始化爲UILabels
我還想要識別不同標籤中的句子何時接近屏幕的末端,然後將下一個單詞放在文本的單詞下方,如在Microsoft Word中按Enter鍵。
我試過這段代碼,但它加載了同一個地方的所有單詞。
- (void)change:(id)sender
{
NSString *sentence = @"i am a boy with passion";
NSArray *array = [sentence componentsSeparatedByCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString:@" "]];
CGFloat xVal = 11.0;
for (NSString *words in array) {
UILabel *labelText = [[UILabel alloc]initWithFrame:CGRectMake(xVal, 50, 300, 80)];
labelText.layer.borderColor = [UIColor blueColor].CGColor;
labelText.layer.borderWidth = 6.0;
labelText.backgroundColor = [UIColor clearColor];
labelText.textColor = [UIColor blackColor];
labelText.font = [UIFont boldSystemFontOfSize:20.0f];
labelText.text = words;
xVal=+200;
[self.view addSubview:labelText];
[labelText setUserInteractionEnabled:YES];
[labelText sizeToFit];
「另外,我想的Xcode時在不同的標籤句子接近屏幕的結束認識」 - 祝你好運,Xcode中沒有做這樣的東西這個。也許你想**你的應用程序**來做到這一點呢? – 2013-07-02 18:29:22
@ H2CO3哦。哇,謝謝你們,如果我自己製作透明標籤,並寫一個代碼把這些標籤中的單詞寫出來,該怎麼辦? –