// Color button
Listchuan = 1;
nsmutablearray *showlabelarray = [nsmutablearrayarraywithcapacity:ten];
for (int i =0; i<7; i++) {
Listchuan+ +;
nsstring *chuanstr = [nsstringstringwithformat:@ "%i election ",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 Span style= "COLOR: #000000" > *BTN = [ uibutton buttonwithtype: uibuttontypecustom];
[btn setbackgroundimage:[ uiimage Imagenamed: @ "Btn_white_small" ] forstate: Uicontrolstatenormal];
[btn settitle: [Showlabelarrayobjectatindex: i*4+j]forstate: uicontrolstatenormal];
[btn settitlecolor: [uicolorblackcolor] forstate:UI Controlstatenormal];
btn. Layer. BorderColor = [uicolorlightgraycolor]. Cgcolor;
Btn. layer. borderWidth =0.7;
Btn. selected =NO;
Btn. frame =cgrectmake(5+j*, +i*, Max.) ;
Btn. tag = i*4+j;
[btn addTarget:self action:@selector(chooselottery:) /c6>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:@] [email Protected] "forstate:uicontrolstatenormal];
button. selected =!button. selected;
}
}
IOS Loop Arrange button (array arrange button) trigger event