oldTag 按钮没有变回白色??我错过了什么?
谢谢
-(void) myCharValue: (UIButton*)btn
{
[btn setBackgroundColor:[UIColor redColor]]; //current tag_button pressed
UIButton *btnTemp;
btnTemp = (UIButton*)[btnChar viewWithTag:oldTag];
[btnTemp setBackgroundColor:[UIColor whiteColor]]; // <--- oldTag button is not changing back to white ??
oldTag = btn.tag;
}
//setup
for (int i=0; i<16; i++) {
for (int j=0; j<16; j++) {
btnChar = [UIButton buttonWithType:UIButtonTypeCustom ];
[btnChar setFrame:CGRectMake(j*40+1, i*40+1, 38, 38)];
[btnChar setBackgroundColor:[UIColor whiteColor]];
[btnChar setTitle:[NSString stringWithFormat:@"%c", k] forState:UIControlStateNormal ];
[btnChar setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[btnChar addTarget:self action:@selector(myCharValue:) forControlEvents:UIControlEventTouchUpInside];
[btnChar setTag:k];
[svDisplay addSubview:btnChar];
k++;
}
}