Production of neon lights (forward, reverse, and stop)

Source: Internet
Author: User
// 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.