IOS cyclic sorting button (array arrangement button) triggers an event
// Color button
ListChuan = 1;
NSMutableArray * showLabelArray = [NSMutableArrayarrayWithCapacity: 10];
For (int I = 0; I <7; I ++ ){
ListChuan ++;
NSString * chuanStr = [NSStringstringWithFormat: @ "% I select", listChuan];
[ShowLabelArrayaddObject: chuanStr];
}
// Add color button
For (int I = 0; I <2; I ++ ){
For (int j = 0; j <4; j ++ ){
If (I = 1 & j = 3 ){
Break;
}
UIButton * btn = [UIButtonbuttonWithType: UIButtonTypeCustom];
[Btn setBackgroundImage: [UIImageimageNamed: @ "btn_white_small"] forState: UIControlStateNormal];
[Btn setTitle: [showLabelArrayobjectAtIndex: I * 4 + j] forState: UIControlStateNormal];
[Btn setTitleColor: [UIColorblackColor] forState: UIControlStateNormal];
Btn. layer. borderColor = [UIColorlightGrayColor]. CGColor;
Btn. layer. borderWidth = 0.7;
Btn. selected = NO;
Btn. frame = CGRectMake (5 + j * 70, 50 + I * 40, 60, 30 );
Btn. tag = I * 4 + j;
[Btn addTarget: selfaction: @ selector (chooseLottery :) forControlEvents: UIControlEventTouchUpInside];
[ChooseBackroundViewaddSubview: btn];
NSLog (@ "btn. tag % d", btn. tag );
}
}
-(Void) chooseLottery :( UIButton *) sender {
UIView * backBround = (UIView *) [self. viewviewWithTag: TOUZHUBACKGROUNVIEW_Tag];
UIButton * button = (UIButton *) sender;
For (int I = 0; I <2; I ++ ){
For (int j = 0; j <4; j ++ ){
If (I = 1 & j = 3 ){
Break;
Button = (UIButton *) [backBroundviewWithTag: I * 4 + j];
}
}
}
If (button. selected = YES)
{
[Button setBackgroundImage: [UIImageimageNamed: @ ""] forState: UIControlStateNormal];
Button. selected =! Button. selected;
}
Else if (button. selected = NO)
{
[Button setBackgroundImage: [UIImageimageNamed: @ "leagueBtn_selected @ 2x"] forState: UIControlStateNormal];
Button. selected =! Button. selected;
}
}