First come to the three gif image!
link form baidu pan
first :main code
{
UIButton * tempBt = sender;
if (tempBt.backgroundColor == [UIColorblackColor]) {
tempBt.backgroundColor = [UIColorredColor];
return;
}else{
tempBt.backgroundColor = [UIColorblackColor];
return;
}
}
second:
{
UIButton *tempBtn = sender;
UIButton *temBt2 ;
NSArray *array = [NSArrayarrayWithObjects:Bt1,Bt2,Bt3,nil];
for (int i =0; i<array.count; i++) {
temBt2 = [array objectAtIndex:i];
temBt2.backgroundColor = [UIColorblackColor];
}
if (Flag1 ==0) {
tempBtn.backgroundColor = [UIColorredColor];
intAddTag++;
tempBtn.tag = intAddTag;
Flag1 = 1;
return;
}
if (Flag1) {
if (intAddTag == tempBtn.tag) {
tempBtn.backgroundColor = [UIColorblackColor];
Flag1 = 0;
}else{
tempBtn.backgroundColor = [UIColorredColor];
intAddTag++;
tempBtn.tag =
intAddTag;
Flag1 = 1;
}
}
}
Third main code:
{
UIButton *tempBtn = sender;
UIButton *temBt2 ;
NSArray *array = [NSArrayarrayWithObjects:Bt1,Bt2,Bt3,nil];
for (int i =0; i<array.count; i++) {
temBt2 = [array objectAtIndex:i];
temBt2.backgroundColor = [UIColorblackColor];
}
tempBtn.backgroundColor = [UIColorredColor];
}