可实现随意切换的button同时随切换改变title的颜色



-(void)btnClick:(UIButton *)sender

{

static int currentSelectButtonIndex = 0;

static int previousSelectButtonIndex=10;

currentSelectButtonIndex=sender.tag;

UIButton *previousBtn=(UIButton *)[self viewWithTag:previousSelectButtonIndex];

[previousBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

UIButton *currentBtn = (UIButton *)[self viewWithTag:currentSelectButtonIndex];;

[currentBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

previousSelectButtonIndex=currentSelectButtonIndex;

NSLog(@">>>>>>>>>%d",currentSelectButtonIndex);

}




你可能感兴趣的:(UI篇)