我知道有类似的问题,但我想我已经尝试了他们的解决方案。
这是我的代码:
NSMutableArray *sls;
for (int c=1;c<6;c++){
for (int r=1;r<6;r++){
UILabel *s = [[UILabel alloc] init];
s.textAlignment= NSTextAlignmentCenter;
s.backgroundColor= [UIColor whiteColor];
s.textColor=[UIColor blackColor];
s.layer.borderColor= [[UIColor cyanColor]CGColor];
s.layer.borderWidth= 2.5;
s.text= [NSString stringWithFormat:@"%d",5*(5*(r-1) + c)];
[s sizeToFit];
[s setFrame:CGRectMake(c*45-20,r*45,s.frame.size.width+8,21)];
[_map addSubview:s];
[sls addObject:s];
}
}
UILabel *t= [sls objectAtIndex:3];
CGPoint c = t.center;
c.y -= 10;
t.center = c;
t.text= @"T";
t.backgroundColor= [UIColor yellowColor];
t.layer.borderColor= [[UIColor magentaColor]CGColor];
t.transform= CGAffineTransformMakeRotation(-35*piO180);
所有标签都添加到数组中,并且在我的_map视图中显示得很好,但我没有对索引3处的UILabel进行任何编辑。
为什么我不能以任何方式更改索引3处的UILabel?谢谢,卡门