から動的にNSMutableArray
ラベルを作成しています。ラベルの作成中に、各ラベルにタグを設定しました。NSMutableArray
という名前のものがありwordArray
ます。ここで、文字列が wordArray で使用できるかどうかを確認したいのですが、次を使用してこれを確認できます。
[wordArray containsObject:wordStr];
ラベルを動的に作成する場合:
UILabel *wordLabl;
int tagValue3 = 1;
for (int iloop = 0; iloop < [wordArray count]; iloop++)
{
wordLabl = [self addwordLabelRect:CGRectMake(80 * iloop + 20, 420 , 100, 20)andTag:tagValue3];//30 + 35 30 * iloop+
[self.view addSubview:wordLabl];
tagValue3 += 1;
}
-(UILabel *)addwordLabelRect:(CGRect)rect andTag:(int)integerValue
{
wordLabel = [[UILabel alloc] init];
wordLabel.frame = rect;
wordLabel.userInteractionEnabled = YES;
wordLabel.tag = integerValue;
wordLabel.backgroundColor = [UIColor clearColor];
wordLabel.font = [UIFont systemFontOfSize:15];
wordLabel.text = [NSString stringWithFormat:@"%@",[wordArray objectAtIndex:integerValue - 1]];
wordLabel.textAlignment = NSTextAlignmentCenter;
wordLabel.textColor = [UIColor whiteColor];
return wordLabel;
}
上記のコードを使用して、ラベルとタグを作成しています。しかし、そのラベルのwordArray
変更したい文字列が含まれている場合、textColor
これは Tag を使用して実行できると思いますが、ラベルのタグ値を取得するにはどうすればよいですか。