// Create a neon view nsarray * arr = [nsarray arraywithobjects: [uicolor purplecolor], [uicolor cyancolor], [uicolor bluecolor], [uicolor greencolor], [uicolor yellowcolor], [uicolor orangecolor], [uicolor redcolor], nil]; for (INT I = 0; I <7; I ++) {uiview * view = [[uiview alloc] initwithframe: cgrectmake (20 + I * 20,120 + I * 20,280-I * 20*2,280-I * 20*2)]; view. backgroundcolor = arr [I]; view. tag = 100 + I; [_ containerview addsubview: View]; [view release];}
// Create a button to control the neon light to stop uibutton * bun = [uibutton buttonwithtype: uibuttontypesystem]; bun. frame = cgrectmake (50,420,220, 40); bun. layer. cornerradius = 5; [bun settitle: @ "stop" forstate: uicontrolstatenormal]; [bun addtarget: Self action: @ selector (BUN :) forcontrolevents: uicontroleventtouchupinside]; [_ containerview addsubview: bun];
// Create a button for the neon to run in reverse direction uibutton * Stop = [uibutton buttonwithtype: uibuttontypesystem]; stop. frame = cgrectmake (50,480,220, 40); stop. layer. cornerradius = 5; [Stop settitle: @ "reverse" forstate: uicontrolstatenormal]; [Stop addtarget: Self action: @ selector (click) forcontrolevents: uicontroleventtouchupinside]; [_ containerview addsubview: stop];
// Set the interval _ time = [nstimer scheduledtimerwithtimeinterval: 0.1 target: Self selector: @ selector (TEST) userinfo: Nil repeats: Yes];
// Stop event-(void) bun :( uibutton *) BTN {[_ time invalidate];}
// Click the event (void) test {uiview * view = [[uiview alloc] init]; view. backgroundcolor = [_ containerview viewwithtag: 100]. backgroundcolor; For (INT I = 100; I <107; I ++) {[_ containerview viewwithtag: I]. backgroundcolor = [_ containerview viewwithtag: I + 1]. backgroundcolor;} [_ containerview viewwithtag: 106]. backgroundcolor = view. backgroundcolor; [view release];}
// Run the Click Event reversely-(void) Click {_ time = [nst1_scheduledtimerwithtimeinterval: 0.3 target: Self selector: @ selector (CLICKS) userinfo: Nil repeats: Yes];} -(void) clicks {uiview * view = [[uiview alloc] init]; view. backgroundcolor = [_ containerview viewwithtag: 106]. backgroundcolor; For (INT I = 106; I> 99; I --) {[_ containerview viewwithtag: I]. backgroundcolor = [_ containerview viewwithtag: I-1]. backgroundcolor;} [_ containerview viewwithtag: 100]. backgroundcolor = view. backgroundcolor; [view release];}
Through the above steps, we have basically completed a neon lamp production that can be forward, reverse, and stopped.
File: // users/lanouhn/desktop/1.gif
Production of neon lights (forward, reverse, and stop)